Documentation
¶
Overview ¶
Package lifecycle coordinates application components and resource cleanup.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyRun = errors.New("lifecycle: application has already run")
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App owns the lifecycle of its components and is run once.
func (*App) Run ¶
Run starts components in order. Cancellation or completion of any component stops the application. Shutdown uses a fresh context with a shared timeout, stops components in reverse order, waits for their exit, then runs Cleanup. Ordinary caller cancellation is a successful shutdown. Component, shutdown and cleanup errors are preserved with errors.Join.
func (*App) RunSignals ¶
RunSignals runs until a component exits, SIGINT or SIGTERM is received.
type Component ¶
Component represents a server or background worker. Start returns when ready; Wait blocks until execution ends and returns nil for normal shutdown. Stop must respect its context and release partially started resources even if Start failed. Stop must also allow Wait to finish.