For example, you develop a TCP service, and deploy the service to K8S.
Case 1: Container restarts because the service process exits abnormally. Problem: It usually takes seconds ~ dozens of seconds before the container is up again. Better Solution: Let the process-level guardian guard your service process. Even though your service process exits abnormally, the container keeps alive, because the guardian keeps alive. The guardian launches your service process instantly, and therefore decreases downtime to 0.
Case 2: Client connections are closed because server process exits. Problem: Clients have to re-connect the server. Better Solution: Let the goroutine-level guardian guard your service goroutine. Even though your service exits abnormally, the process keeps alive, because the guardian keeps alive. The guardian launches your service instantly, and therefore decreases downtime to 0. Furthermore, all established connections remain intact.
Case 3: Auto-restart service on config change. Problem: Same as Case 1 and 2. Better Solution: Let the auto-reloader watch the config file, and reload your service on config changes. It avoids container restart and process restart, and therefore decreases downtime to 0. Furthermore, all established connections remain intact.
Readiness is a TCP Server for readiness check (aka, health check). Only for connectivity check. For security purpose, no sending data nor receiving data.
A Timeout Decorator abandons the call to the wrapped function if the call does not finish in a specified duration. There’re 4 variants, each for a type of functions. All functions can be classfied into these four.