Skip to content

2024

User Process Management CLI

Generally, it's common to have a cli tool to manage the user processes, with respective commands to help start, stop, restart processes like systemctl. This blog records some experience building a CLI tool in Go to manage processes. Moreover, it lists some sceneries to make it work well as a PID 1 process.

Here are some summary items in this blog:

  • signal handling, wait system calls and process management
  • processes reaping as the init process
  • start, restart and exit handling

Understand Monad Transformers

Monad transformer(monadT) is another significant concept in Haskell. To understand the monadT, it's compulsory to know how monad works and the mechanism of >>=(bind). You can view the blog Understand Monad or any popular monads to learn about them.

In this blog, I will convey how we use monad transformer while how we recognize the idea that monad transformer creates a new monad. I will explain the function lift as well.

Go Reflect: Fail to Set Argument Value During Conversion

This blog records the failure when trying to set the response value using reflect to provide an adaptor for wrapping the original PRC interceptor to the custom interceptor format defined by our tech products.

The difference between them is the custom interceptor moves the response from an argument to a response. This blog introduces the challenges encountered while designing an adaptor.

Signatures of Original RPC Interceptor And Custom Interceptor
// package rpc
// original RPC interceptor signature
type Interceptor func(ctx context.Context, 
    request, response interface{}, processor Processor) uint32
type Processor func(ctx context.Context, request, response interface{}) uint32


// package custom
// interceptor in the tech team
type CustomInterceptor interface {
    Wrap(HandlerFn) HandlerFn
}
type HandlerFn func(ctx context.Context, req interface{}) (interface{}, error)