Documentation
¶
Overview ¶
Package shutdown provides graceful shutdown handling for the DAST crawler.
Index ¶
- func Register(name string, callback ShutdownCallback)
- func RegisterFunc(name string, fn func())
- func SetGlobal(h *Handler)
- func Shutdown()
- type Config
- type Coordinator
- type GracefulServer
- type Handler
- func (h *Handler) Context() context.Context
- func (h *Handler) Done() <-chan struct{}
- func (h *Handler) IsShuttingDown() bool
- func (h *Handler) ListenAndShutdown() <-chan struct{}
- func (h *Handler) Register(name string, callback ShutdownCallback)
- func (h *Handler) RegisterFunc(name string, fn func())
- func (h *Handler) RegisterServer(name string, server GracefulServer)
- func (h *Handler) Shutdown()
- func (h *Handler) ShutdownNow()
- func (h *Handler) Trigger()
- func (h *Handler) Wait()
- func (h *Handler) WaitWithContext(ctx context.Context)
- type ShutdownCallback
- type ShutdownResult
- type TimeoutError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(name string, callback ShutdownCallback)
Register registers a callback with the global handler.
func RegisterFunc ¶
func RegisterFunc(name string, fn func())
RegisterFunc registers a function with the global handler.
Types ¶
type Config ¶
type Config struct {
Timeout time.Duration
Signals []os.Signal
OnShutdownStart func()
OnShutdownDone func(elapsed time.Duration, errors []error)
}
Config holds shutdown configuration.
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator coordinates multiple shutdown handlers.
func (*Coordinator) Add ¶
func (c *Coordinator) Add(h *Handler)
Add adds a handler to the coordinator.
func (*Coordinator) ShutdownAll ¶
func (c *Coordinator) ShutdownAll()
ShutdownAll triggers shutdown on all handlers.
func (*Coordinator) WaitAll ¶
func (c *Coordinator) WaitAll()
WaitAll waits for all handlers to complete shutdown.
type GracefulServer ¶
GracefulServer wraps a component that needs graceful shutdown.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler manages graceful shutdown.
func NewDefault ¶
func NewDefault() *Handler
NewDefault creates a handler with default configuration.
func (*Handler) Context ¶
Context returns the shutdown context. This context is cancelled when shutdown begins.
func (*Handler) Done ¶
func (h *Handler) Done() <-chan struct{}
Done returns a channel that is closed when shutdown completes.
func (*Handler) IsShuttingDown ¶
IsShuttingDown returns whether shutdown is in progress.
func (*Handler) ListenAndShutdown ¶
func (h *Handler) ListenAndShutdown() <-chan struct{}
ListenAndShutdown starts listening for signals and handles shutdown. Returns a channel that receives when shutdown is complete.
func (*Handler) Register ¶
func (h *Handler) Register(name string, callback ShutdownCallback)
Register registers a shutdown callback with a name.
func (*Handler) RegisterFunc ¶
RegisterFunc registers a simple cleanup function.
func (*Handler) RegisterServer ¶
func (h *Handler) RegisterServer(name string, server GracefulServer)
RegisterServer registers a GracefulServer for shutdown.
func (*Handler) ShutdownNow ¶
func (h *Handler) ShutdownNow()
ShutdownNow initiates immediate shutdown without waiting for callbacks.
func (*Handler) Trigger ¶
func (h *Handler) Trigger()
Trigger manually triggers shutdown (for testing or programmatic shutdown).
func (*Handler) WaitWithContext ¶
WaitWithContext waits for shutdown or context cancellation.
type ShutdownCallback ¶
ShutdownCallback is a function called during shutdown.
type ShutdownResult ¶
ShutdownResult holds the result of a shutdown operation.
func (*ShutdownResult) HasErrors ¶
func (r *ShutdownResult) HasErrors() bool
HasErrors returns whether any errors occurred during shutdown.
type TimeoutError ¶
type TimeoutError struct {
CallbackName string
}
TimeoutError is returned when a callback times out.
func (*TimeoutError) Error ¶
func (e *TimeoutError) Error() string