Documentation
¶
Overview ¶
Package shutdown provides coordinated graceful shutdown management for RabbitMQ components and other closable resources. It handles signal management, timeout control, and tracking of in-flight operations during shutdown.
Index ¶
- type Closable
- type Field
- type InFlightTracker
- type Logger
- type NoOpLogger
- type ShutdownConfig
- type ShutdownManager
- func (sm *ShutdownManager) GetInFlightTracker() *InFlightTracker
- func (sm *ShutdownManager) IsShutdown() bool
- func (sm *ShutdownManager) IsShutdownComplete() bool
- func (sm *ShutdownManager) Register(component Closable)
- func (sm *ShutdownManager) RegisterComponent(component rabbitmq.Closable) error
- func (sm *ShutdownManager) SetupSignalHandler() <-chan os.Signal
- func (sm *ShutdownManager) SetupSignalHandling() <-chan struct{}
- func (sm *ShutdownManager) Shutdown()
- func (sm *ShutdownManager) ShutdownGracefully(ctx context.Context) error
- func (sm *ShutdownManager) Wait()
- func (sm *ShutdownManager) WaitWithContext(ctx context.Context) error
- type SimpleField
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Closable ¶
type Closable interface {
Close() error
}
Closable interface for components that can be gracefully closed
type InFlightTracker ¶
type InFlightTracker struct {
// contains filtered or unexported fields
}
InFlightTracker tracks in-flight operations for graceful shutdown
func NewInFlightTracker ¶
func NewInFlightTracker() *InFlightTracker
NewInFlightTracker creates a new in-flight operations tracker
func (*InFlightTracker) Close ¶
func (ift *InFlightTracker) Close() error
Close prevents new operations and waits for existing ones to complete
func (*InFlightTracker) CloseWithTimeout ¶
func (ift *InFlightTracker) CloseWithTimeout(timeout time.Duration) error
CloseWithTimeout waits for in-flight operations with a timeout
func (*InFlightTracker) Done ¶
func (ift *InFlightTracker) Done()
Done marks the completion of an operation
func (*InFlightTracker) IsClosed ¶
func (ift *InFlightTracker) IsClosed() bool
IsClosed returns true if the tracker is closed
func (*InFlightTracker) Start ¶
func (ift *InFlightTracker) Start() bool
Start marks the beginning of an operation
type Logger ¶
type Logger interface {
Debug(msg string, fields ...Field)
Info(msg string, fields ...Field)
Warn(msg string, fields ...Field)
Error(msg string, fields ...Field)
}
Logger interface for structured logging
type NoOpLogger ¶
type NoOpLogger struct{}
NoOpLogger provides a no-operation logger implementation
func (NoOpLogger) Debug ¶
func (l NoOpLogger) Debug(msg string, fields ...Field)
func (NoOpLogger) Error ¶
func (l NoOpLogger) Error(msg string, fields ...Field)
func (NoOpLogger) Info ¶
func (l NoOpLogger) Info(msg string, fields ...Field)
func (NoOpLogger) Warn ¶
func (l NoOpLogger) Warn(msg string, fields ...Field)
type ShutdownConfig ¶
type ShutdownConfig struct {
Timeout time.Duration // Overall shutdown timeout
SignalTimeout time.Duration // Additional time to wait after receiving signal
GracefulDrainTime time.Duration // Time to allow for in-flight operations to complete
Logger Logger // Logger for shutdown events
}
ShutdownConfig holds configuration for the shutdown manager
func DefaultShutdownConfig ¶
func DefaultShutdownConfig() ShutdownConfig
DefaultShutdownConfig returns sensible default shutdown configuration
type ShutdownManager ¶
type ShutdownManager struct {
// contains filtered or unexported fields
}
ShutdownManager provides coordinated graceful shutdown for RabbitMQ components
func NewShutdownManager ¶
func NewShutdownManager(config ShutdownConfig) *ShutdownManager
NewShutdownManager creates a new shutdown manager
func (*ShutdownManager) GetInFlightTracker ¶
func (sm *ShutdownManager) GetInFlightTracker() *InFlightTracker
GetInFlightTracker returns the in-flight operations tracker
func (*ShutdownManager) IsShutdown ¶
func (sm *ShutdownManager) IsShutdown() bool
IsShutdown returns true if shutdown has been initiated
func (*ShutdownManager) IsShutdownComplete ¶
func (sm *ShutdownManager) IsShutdownComplete() bool
IsShutdownComplete implements the simplified GracefulShutdown interface
func (*ShutdownManager) Register ¶
func (sm *ShutdownManager) Register(component Closable)
Register adds a component to be managed during shutdown
func (*ShutdownManager) RegisterComponent ¶
func (sm *ShutdownManager) RegisterComponent(component rabbitmq.Closable) error
RegisterComponent implements the simplified GracefulShutdown interface
func (*ShutdownManager) SetupSignalHandler ¶
func (sm *ShutdownManager) SetupSignalHandler() <-chan os.Signal
SetupSignalHandler sets up signal handling for graceful shutdown
func (*ShutdownManager) SetupSignalHandling ¶
func (sm *ShutdownManager) SetupSignalHandling() <-chan struct{}
SetupSignalHandling implements the simplified GracefulShutdown interface
func (*ShutdownManager) Shutdown ¶
func (sm *ShutdownManager) Shutdown()
Shutdown performs graceful shutdown of all registered components
func (*ShutdownManager) ShutdownGracefully ¶
func (sm *ShutdownManager) ShutdownGracefully(ctx context.Context) error
ShutdownGracefully implements the simplified GracefulShutdown interface
func (*ShutdownManager) Wait ¶
func (sm *ShutdownManager) Wait()
Wait blocks until shutdown is complete
func (*ShutdownManager) WaitWithContext ¶
func (sm *ShutdownManager) WaitWithContext(ctx context.Context) error
WaitWithContext blocks until shutdown is complete or context is cancelled
type SimpleField ¶
type SimpleField struct {
// contains filtered or unexported fields
}
SimpleField implements the Field interface for simple key-value pairs
func (SimpleField) Key ¶
func (f SimpleField) Key() string
func (SimpleField) Value ¶
func (f SimpleField) Value() any