Documentation
¶
Overview ¶
Package lifecycle provides graceful shutdown coordination for GRIP components.
It exposes the Shutdown coordinator which supports:
- Idempotent shutdown initiation
- LIFO hook execution (last registered, first executed)
- Shutdown reason tracking
- Context-based cancellation propagation
Usage ¶
sd := lifecycle.NewShutdown()
sd.Register(func() { server.GracefulStop() })
sd.Register(func() { db.Close() })
// Later, during shutdown:
sd.Shutdown("SIGTERM received")
// Hooks execute in reverse order: db.Close() then server.GracefulStop()
The Shutdown coordinator is thread-safe and can be shared across multiple GRIP pipelines.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Shutdown ¶
Shutdown coordinates graceful shutdown of GRIP components.
It implements core.ShutdownCoordinator and provides:
- Idempotent shutdown initiation
- LIFO hook execution
- Shutdown reason tracking
- Context-based cancellation propagation
func NewShutdown ¶
func NewShutdown() *Shutdown
NewShutdown creates a new shutdown coordinator.
The returned coordinator is ready to use and can be shared across multiple GRIP components:
sd := lifecycle.NewShutdown() u := unary.New(unary.WithShutdown(sd)) s := serverstream.New(serverstream.WithShutdown(sd))
type ShutdownHook ¶
type ShutdownHook = lifecycle.ShutdownHook
ShutdownHook is a function called during shutdown. Hooks are executed in LIFO order.
Click to show internal directories.
Click to hide internal directories.