• v1.0.0 8d6930b087

    Rene Nochebuena released this 2026-05-11 19:06:12 -06:00 | 1 commits to main since this release

    v1.0.0

    code.nochebuena.dev/go/health

    Overview

    health v1.0.0 commits the HTTP health check API as stable. All v0.9.0 roadmap
    items are resolved. The module ships a parallel check handler with two-level
    criticality, a configurable check timeout, and a pure stdlib footprint. No
    external or internal micro-lib imports required.

    What Changed Since v0.9.0

    New: Config and NewHandlerWithConfig

    type Config struct {
        CheckTimeout time.Duration // 0 → 5s default
    }
    
    func NewHandlerWithConfig(logger Logger, cfg Config, checks ...Checkable) http.Handler
    

    The check timeout is now configurable. NewHandler remains unchanged and
    continues to use the 5-second default.

    // Default — identical to v0.9.0
    h := health.NewHandler(logger, db, cache)
    
    // Custom 2-second timeout for SLO-sensitive probes
    h := health.NewHandlerWithConfig(logger, health.Config{CheckTimeout: 2 * time.Second}, db, cache)
    

    Roadmap items resolved

    Item Resolution
    Configurable check timeout Config.CheckTimeout via NewHandlerWithConfig
    Result caching (TTL-based) No — load balancer probe spacing controls frequency
    Timeout vs error distinction in JSON No — the error field is sufficient for current use
    Buffer channel goroutine-leak documentation Validated — checks are fixed at construction time (correct by design)
    Parallel checks under probe traffic Validated in production

    Full API (stable)

    LevelLevelCritical (0, default) and LevelDegraded (1).

    CheckableHealthCheck(ctx) error, Name() string, Priority() Level.

    Logger — duck-typed interface satisfied by logz.Logger with no import required.

    ComponentStatus{ status, latency, error } JSON fields.

    Response{ status, components } JSON fields.

    ConfigCheckTimeout time.Duration; zero value → 5 seconds.

    NewHandler(logger, checks...) http.Handler — backward-compatible constructor, 5s timeout.

    NewHandlerWithConfig(logger, cfg, checks...) http.Handler — constructor with explicit config.

    Migration from v0.9.0

    No breaking changes. NewHandler is unchanged.

    go get code.nochebuena.dev/go/health@v1.0.0
    
    Downloads