“Tests are stories we tell the next generation of programmers on a project.”
— Roy Osherove, The Art of Unit Testing
An application contains small amount of components, it could be a struct, function or class, we call it unit components, and our application reliability is depends on this unit components. We should make sure the unit components don’t break our application.
Redis (Remote Dictionary Server) is a in memory data store which can we used as a database, cache, and message broker. The most apparent use cases for Redis is as cache store on the server side. Aside for caching, there are some patterns that can help use to solve our common problems.
You have a public end point, and you want to limit access to to the end point based on client IP address. Let’s say we want to limit the access by 100 requests per minute. By using built in Redis GET and INCR function, we can build out…
On multithreaded programming environment, we use locks to limit access to shared resources. An example of a lock is a mutex, it name stand for mutual exclusion. A mutex is used to guard shared data (array, linked list, hash map or any simple primitive type) by allowing only a single thread to access the shared data.
When it came to distributed system, it is hard to ensure our multiple instances of applications doing exactly one same piece of work at a time. For example calling some external API, writing to external storage, and perform some heavy computations. …
In Go programming language, we can achieve concurrency by using goroutine. Goroutine is one of the most basic units Go programming language. When we create go program, it has at least one goroutine, we called it the main goroutine, it is automatically created and started when the main process begin.
By combining Go’s concurrency primitives (goroutine and channel) and built-in sync package, we can build a pattern to help us writing maintainable concurrent Go code. There are many patterns can be implemented using Go, for example Fan-in Fan-out, Generator, Job Queue, Pipeline, Semaphore, Worker Pool etc.
Each pattern has it…
Since version 2.0, Kong announced Go as one of the supported languages to be used on Kong API Gateway plugins development besides Lua. Kong releases the Plugin Development Kit (PDK) for Go users on their official repository. In this article, we’ll try to develop and deploy custom plugins for Kong 2.3 using Go.
# Stage 1 - Build plugin
# Pull image from official go-plugin-tool.FROM kong/go-plugin-tool:2.0.4-alpine-latest AS builder
# Copy current workspace to container.RUN mkdir -p…
Implementing concurrent processes in the Go programming language is very easy. Just run your function with go prefix, and boooom, your function will not blocking your main Goroutine.
But, what if your awesome concurrent function have responsibility with the machine’s I/O? For example, your function will do 100 parallel HTTP POST request to REST API from other services. Yeah, your network I/O will be busy handling 100 requests concurrently and this can slow down your I/O performance.
Here comes the rescue Semaphore, based on Wikipedia,
“Semaphore is a variable or abstract data type used to control access to a common…
“Concurrency is about dealing with lots of things at once. Parallelism is about doing lots of things at once.” — Rob Pike
What is the meaning of concurrency in programming?
Concurrency is the ability of a program for running multiple tasks simultaneously.
And what is parallelism ?
Parallelism is about doing multiple tasks at once.
Model View ViewModel (MVVM) merupakan salah satu architectural pattern yang dipakai dalam pengembangan perangkat lunak berbasis Graphical User Interface (GUI), arsitektur ini memisahkan business logic dengan GUI. Pada Android SDK sendiri, telah tersedia library Data Binding dari API level 7+.
Beberapa layer pada arsitektur MVVM :
Model / entity adalah representasi dari data yang digunakan pada business logic, dapat berupa Plain Old Java Object (POJO), Kotlin Data Classes, dll.
Representasi UI dari sebuah aplikasi, pada Android sendiri view ini dapat berupa Activity atau Fragment.
Layer yang berinteraksi langsung dengan Model, serta menyajikan data untuk View layer.