package lifecycle // Component is the lifecycle interface implemented by all managed infrastructure // components. The framework calls OnInit on every registered component, then runs // BeforeStart hooks, then calls OnStart. OnStop is called in reverse registration // order during graceful shutdown. Returning a non-nil error from any hook aborts // the phase and triggers shutdown. type Component interface { // OnInit initializes the component: open connections, allocate resources. // Called sequentially for all components before any OnStart is invoked. OnInit() error // OnStart starts background services — goroutines, listeners, background loops. // Called after all OnInit calls succeed and all BeforeStart hooks have run. OnStart() error // OnStop stops the component and releases all resources. // Called in reverse registration order during graceful shutdown. OnStop() error }