Documentation
¶
Overview ¶
Package runner provides an application lifecycle manager for coordinated startup and graceful shutdown.
Services are registered in two tiers: infrastructure (database, cache, queue) and core (API handlers). Infrastructure services start first; if any fail, the application exits immediately. Core services start afterward. On shutdown, core services stop first, then infrastructure. The entire shutdown is bounded by a configurable timeout (default 30 seconds). Service panics are caught and logged.
Basic usage:
r := runner.New(
runner.WithInfrastructureService(dbService),
runner.WithInfrastructureService(cacheService),
runner.WithCoreService(apiServer),
runner.WithShutdownTimeout(30*time.Second),
)
r.Run() // Blocks until SIGINT/SIGTERM; calls os.Exit(1) on error
Each service must implement the Service interface (Start, Stop, Name). Startup failures in any tier abort the application immediately.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Runner)
func WithCoreService ¶
func WithShutdownTimeout ¶
Click to show internal directories.
Click to hide internal directories.