LabKit v2: app package

Overview

Implement the app package for LabKit v2 — the central application lifecycle coordinator. Services register pluggable Component implementations and App handles ordered startup and reverse-ordered graceful shutdown.

Any struct that implements Start(ctx) error and Shutdown(ctx) error can be registered, making it easy to add new infrastructure components without touching startup wiring. app also threads the shared logger and tracer through to every subsystem automatically.

Example usage

a, _ := app.New(ctx)

db, _ := postgres.NewWithConfig(&postgres.Config{DSN: dsn, Tracer: a.Tracer()})
srv := httpserver.NewWithConfig(&httpserver.Config{Logger: a.Logger(), Tracer: a.Tracer()})

a.Register(db)
a.Register(srv)

a.Start(ctx)    // starts db, then srv
a.Shutdown(ctx) // shuts down srv, then db (reverse order)

Reference