Circuit breaker in electrical terms is an automatically switch designed to protect an electrical circuit from damage caused by excess current from an overload or short circuit.

in the role of software development, circuit breaker is a design pattern use to detects failures and prevents the application from trying to perform the action that is doomed to fail until it’s safe to retry and protecting resource and help services or a server to perform recovery.

the main idea of a circuit breaker works is by creating a wrapper or function to call the circuit breaker object to monitor failures. When…


Clean Architecture

Clean architecture is a software design philosophy that separates the elements of a design into ring levels. The main rule of clean architecture is that code dependencies can only come from the outer levels inward. Code on the inner layers can have no knowledge of functions on the outer layers. it contains delivery, usecase, repository in general.

GraphQL

GraphQL is a query language for your API, and a server-side runtime for executing queries by using a type system you define for your data. …


Introduction

Recently there has been news about hacker claim that they are stealing data from website or an organization affecting sensitive data of million customers made public and sold for a certain price. however organization have the responsibility to protect their customers data.

At this point, we want to protect customer data from database layer, even if it was steal by a group of hacker or someone can gain access to database. but the hacker cannot read at some private data in some column because its encrypted by private/public key. so, whoever steal your data. …


coverage sunburst graph

Code coverage is a measurement used to express which lines of code were executed by a test suite. A program with high test coverage, measured as a percentage, has had more of its source code executed during testing, which suggests it has a lower chance of containing undetected software bugs compared to a program with low test coverage.

monorepo is a software development strategy where code for many projects is stored in the same repository.

in monorepo you will have multiple project with mutliple coverage based on the project in monorepo. …


RethinkDB is an open source distributed data source for realtime web apps with JSON based document. RethinkDB has intuitive query language, parallelized queries, and simple administration tools.

rethinkDB also has modern web UI. located in http://localhost:8080 if you install in local environment.


in my previous post, i already post about how to setup new go application into bazel monorepo. you can check my previous post here .

Alright, we’’ll get to the point by setting up the Go application that is already running into the bazel monorepo

1. copy the existing project into the monorepo folder. assuming we will name it `go-existing` and save it in the `packages` folder

2. create BUILD.bazel file in the go application root folder:

load("@bazel_gazelle//:def.bzl", "gazelle")# gazelle:prefix github.com/hardyantz/go-hello-worldgazelle(name = "gazelle")load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")go_binary(
name = "hello-world",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)

in…


ini this section, you’ll learn the basic of building go application with bazel(https://www.bazel.build/) and gazelle (https://github.com/bazelbuild/bazel-gazelle)

first install bazel, if you don’t have it, install bazel here :(https://docs.bazel.build/versions/2.0.0/install.html)

lets create hello-world project with go language.

create folder packages, WORKSPACE file, & BUILD.bazel file in root project.

bazel-go
└── packages
├──hello-world
│ ├── main.go
│ ├── BUILD.bazel
│ ├── ext
│ │ ├── counting.go
├──WORKSPACE
├──BUILD.bazel

packages folder is a folder to store multiple project.

create folder hello-world in packages folder (packages/hello-world).

now, lets create a simple hello-world and its dependency.
create file main.go in folder packages/hello-world :
main.go

package main


Retention log setup

Log retention setup is The minimum age of a log file to be eligible for deletion due to age, means that kafka will save message for period of hours. default is 168 hours or 7 days, to change this setup edit `config/server.properties` and change the value of

log.retention.hours=168

Partition

in kafka, you can set numbers of partition you want to setup.

How to :

Edit config file
edit config file in `config/server.properties` and change the value of

num.partitions=3

you can set the default number of log partitions per topic. …


Producer & Consumer

Create topic
open different new terminal, go to kafka folder and run / type

$ ./bin/kafka-topics.sh — create — zookeeper localhost:2181 — replication-factor 1 — partitions 1 — topic test

Run consumer
open different new terminal, go to kafka folder and run / type

$ ./bin/kafka-console-consumer.sh — bootstrap-server localhost:9092 — topic test

Run producers
open different new terminal, go to kafka folder and run / type

$ ./bin/kafka-console-producer.sh — broker-list localhost:9092 — topic test

type something in the new line in the producer screen

> test one
> test two

open the consumers terminal and the results will be

test…


Install Kafka

this is a step by step to install kafka for messaging system

Verify java
make sure you already install java.

Download kafka
* download kafka source (https://www.apache.org/dyn/closer.cgi?path=/kafka/2.0.0/kafka_2.11-2.0.0.tgz)
* extract source & change directory to kafka directory

$ tar -xzf kafka_2.11–2.0.0.tgz
$ cd kafka_2.11–2.0.0

Start zookepeer server
open new terminal and run / type

$ ./bin/zookeeper-server-start.sh config/zookeeper.properties

Start kafka server
open different new terminal, go to kafka folder and run / type

$ ./bin/kafka-server-start.sh config/server.properties

<< Part 1 — Apache Kafka for Beginners (Part 1 — Basic Kafka)

Apache Kafka for Beginners (Part 3 — Producer & Consumer) — Part 3 >>

Buyung Hardiansyah

Software Developer, Daily Indonesian Gopher.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store