chi.rocks / docs

Distributed Systems & Backend Notes

Internal reference handbook covering Go service patterns, PostgreSQL query planning, idempotent webhook processing, and telemetry pipelines.

Idempotent Event Consumers

Designing transactional outbox consumers and deduplication keys under at-least-once delivery guarantees.

Architecture

PostgreSQL Indexing & sqlc

Composite B-tree selectivity, partial indexes for state machines, and type-safe query generation in Go.

Database

OpenTelemetry & PromQL

Structured trace propagation, tail-based sampling thresholds, and SLO burn-rate alerting rules.

SRE
// Example: graceful shutdown with bounded drain context
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
    slog.Error("server exited", "err", err)
}