Documentation
¶
Overview ¶
Package lifecycle supervises process readiness, ordered drain and resource ownership. It knows nothing about application modules, transports or configuration sources.
Index ¶
- Variables
- type Config
- type Process
- type Runner
- type Runtime
- func (a *Runtime) Close(ctx context.Context) error
- func (a *Runtime) Own(name string, close func(context.Context) error)
- func (a *Runtime) OwnClient(name string, close func() error)
- func (a *Runtime) Ready() <-chan struct{}
- func (a *Runtime) Run(ctx context.Context, processes ...Process) error
- func (a *Runtime) Stopping() <-chan struct{}
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Process ¶
Process names a runner and its drain phase. Lower phases stop first; all runners in the same phase are canceled together before any are joined.
type Runner ¶
Runner owns its work until Run returns. Cancellation stops admission and drains or cancels in-flight work. Ready closes only after startup succeeds. Every process implements the same contract, including native library adapters.
func AfterReady ¶
AfterReady delays a process until all prerequisites are ready. Cancellation while waiting never starts the underlying process.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime owns one execution and the resources acquired for it. Register resources before Run, then Close after Run returns. Close refuses to release dependencies while work is active, including work that outlives the shutdown budget. Own is construction-only; Run and Close are safe against concurrent calls.
func (*Runtime) Close ¶
Close releases resources once in reverse construction order. Call it after execution returns, with an uncanceled context. It applies the cleanup deadline, preserves context values, and refuses to close resources still in use. Commands must join their goroutines before returning.
func (*Runtime) Ready ¶
func (a *Runtime) Ready() <-chan struct{}
Ready closes after every selected process has become ready.