Pattern

Go Pattern: Hybrid Handler

Go Pattern: Hybrid Handler

Overview In today’s high-performance and concurrent computing environments, effectively processing a stream of messages using a mix of purely computational functions and remote procedure calls has become a significant challenge. The Go programming language is designed to handle concurrency well, but when it comes to managing a hybrid load, even Go can struggle to achieve optimal CPU utilization. In this article, we will discuss the Hybrid Handler pattern, an efficient and unified approach to address this challenge.

Read More
Go Pattern: Runner

Go Pattern: Runner

Again and again, a concurrent pattern emerges from the need to control goroutine lifecycles and handle their errors, and I call it the “Runner Pattern”.

Read More
Go Anti-pattern: Parent Closer

Go Anti-pattern: Parent Closer

Imagine you need to wrap multiple objects which implements io.Closer, e.g. three clients to fetch and combine data from different endpoints.

Read More
Go Pattern: Context-aware Lock

Go Pattern: Context-aware Lock

We often use Mutex or RWMutex as locks in Go, but sometimes we need a lock that can be cancelled by a context during the lock attempt.

Read More
Go Pattern: Buffered Writer

Go Pattern: Buffered Writer

A buffered writer is so ubiquitous that we do not usually consider it as a pattern, but sometimes we reinvent it or even do it in an inferior way. Let us look at a real use case first.

Read More