{"modulePath":"github.com/uber/submitqueue","version":"v0.3.0-20261125210437-add1a4bd2ea2","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package lifecycle\n\nPackage 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.\n\n## Types\n\n```go\ntype Component interface {\n\t// Start initializes and starts the component. The context governs the\n\t// start-up phase (e.g. connecting, subscribing); long-running work may\n\t// outlive the context and must be terminated by calling Stop.\n\tStart(ctx context.Context) error\n\n\t// Stop gracefully shuts down the component. The context provides a\n\t// deadline for the shutdown; implementations should respect it and\n\t// return promptly when the context is cancelled.\n\tStop(ctx context.Context) error\n}\n```\nComponent is anything with a lifecycle. Construct returns one; hosts drive it.\n\n```go\ntype Group struct {\n\t// contains filtered or unexported fields\n}\n```\nGroup runs an ordered list of Components as one Component.\n\n  - 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.\n  - Stop: members in REVERSE order (work-acceptors drain before the connections under them close); errors joined, none swallowed.\n\n```go\nfunc NewGroup(members ...Component) *Group\n```\nNewGroup creates a Group from the given components. Nil members are silently skipped so callers can pass optional components without nil-checking.\n\n```go\nfunc (g *Group) Start(ctx context.Context) error\n```\nStart starts all members in order. If any member fails to start, all previously started members are stopped in reverse order and the original start error is returned. The stop errors from rollback, if any, are joined with the start error.\n\n```go\nfunc (g *Group) Stop(ctx context.Context) error\n```\nStop stops all members in reverse order. All stop errors are joined so none is swallowed; a single member's failure does not prevent the others from being stopped.\n\n","path":"github.com/uber/submitqueue/platform/lifecycle","name":"lifecycle","synopsis":"Package lifecycle provides the Component interface and Group type for managing ordered start/stop lifecycles.","isRedistributable":true}
