Documentation
¶
Overview ¶
Package lifecycle provides the Component interface and Group type for managing ordered start/stop lifecycles. Every runnable subsystem (consumer, publisher, server) implements Component; Group composes them into a single Component with deterministic ordering and rollback on partial failure.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component interface {
// Start initializes and starts the component. The context governs the
// start-up phase (e.g. connecting, subscribing); long-running work may
// outlive the context and must be terminated by calling Stop.
Start(ctx context.Context) error
// Stop gracefully shuts down the component. The context provides a
// deadline for the shutdown; implementations should respect it and
// return promptly when the context is cancelled.
Stop(ctx context.Context) error
}
Component is anything with a lifecycle. Construct returns one; hosts drive it.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group runs an ordered list of Components as one Component.
- Start: members in order; if member i fails to start, members i-1…0 are stopped in reverse and the error is returned — no half-started state.
- Stop: members in REVERSE order (work-acceptors drain before the connections under them close); errors joined, none swallowed.
func NewGroup ¶
NewGroup creates a Group from the given components. Nil members are silently skipped so callers can pass optional components without nil-checking.
Click to show internal directories.
Click to hide internal directories.