Documentation
¶
Overview ¶
Package sigutil provides signal-handling utilities for graceful cleanup.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SignalCleanupGuard ¶
type SignalCleanupGuard struct {
// contains filtered or unexported fields
}
SignalCleanupGuard ensures a cleanup function runs exactly once when the process exits normally, on error, or via SIGINT/SIGTERM. Create one via NewSignalCleanupGuard and defer its Close method.
func NewSignalCleanupGuard ¶
func NewSignalCleanupGuard(cleanup func(), logger *slog.Logger) *SignalCleanupGuard
NewSignalCleanupGuard registers SIGINT and SIGTERM handlers that invoke the cleanup function exactly once. The caller must defer Close() to ensure cleanup runs on normal/error exit and the signal handler is deregistered. A nil cleanup function is treated as a no-op.
func (*SignalCleanupGuard) Close ¶
func (g *SignalCleanupGuard) Close()
Close performs cleanup (if not already done) and deregisters the signal handler.
Click to show internal directories.
Click to hide internal directories.