Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aware ¶
Aware is an optional extension for tools or components that need startup/shutdown. The caller checks via type assertion and registers the hook automatically.
type Hook ¶
type Hook struct {
Name string
OnStart func(ctx context.Context) error
OnStop func(ctx context.Context) error
}
Hook is a startup/shutdown pair. Either field may be nil. Name is optional — when set it appears in all lifecycle log output for this hook.
type Lifecycle ¶
type Lifecycle interface {
Append(Hook)
}
Lifecycle collects ordered hooks. Agents and servers register hooks in their Create/New calls; the engine or runner drives Start/Stop.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the concrete, engine-owned implementation of Lifecycle. Hooks start in append order and stop in reverse order. Every hook transition is logged automatically; callers do not need their own logging.
func (*Manager) Hooks ¶
Hooks returns a copy of the chain in start order, so a caller can inspect a default chain before deciding what to change without mutating it by accident.
func (*Manager) Index ¶
Index returns the position of the first hook with this name, or -1. Names are how adopters address steps; positions shift as other steps are added.
func (*Manager) Insert ¶
Insert places h at index i, clamped to the ends of the chain. Chains built by a library are edited by adopters (a step before the swap, a step after the commit), and Append alone can only ever add to the end.
func (*Manager) Remove ¶
Remove drops the first hook with this name and reports whether one existed.