Documentation
¶
Overview ¶
Package lifecycle provides a Manager that starts a set of lifecycle-managed clients in registration order and stops them in reverse for graceful shutdown, so a composition root wires its clients once and coordinates their startup and teardown centrally instead of by hand.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager starts registered clients in registration order and stops them in reverse order, so dependencies come up before dependents and shut down after them. It is not safe for concurrent Register during Start/Stop; register at the composition root, then run.
func (*Manager) Register ¶
func (m *Manager) Register(name string, client interfaces.Lifecycle)
Register adds a lifecycle-managed client under a name. Registration order is the start order; the reverse is the stop order.
type NoOp ¶
type NoOp struct{}
NoOp is an embeddable no-op Lifecycle for stateless clients that hold no persistent connection (SDK clients whose every call is an independent request): Start and Stop do nothing. Embed it so such a client satisfies interfaces.Lifecycle without re-declaring the identical no-op methods on each backend.