Documentation ¶
Overview ¶
Package signal provides convenience methods for intercepting and handling OS signals.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var InterruptSignal = syscall.SIGINT //nolint:gochecknoglobals
InterruptSignal is an interrupt signal.
var InterruptSignals = []os.Signal{syscall.SIGTERM, syscall.SIGINT} //nolint:gochecknoglobals
InterruptSignals contains a list of signals that are treated as interrupts.
Functions ¶
func Notifier ¶
func Notifier(notifyFn NotifyFunc, trackSignals ...os.Signal)
Notifier registers a handler for receiving signals from the OS. When signal is receiving, it calls the given callback func `notifyFn`.
func NotifierWithContext ¶
func NotifierWithContext(ctx context.Context, notifyFn NotifyFunc, trackSignals ...os.Signal)
NotifierWithContext does the same as `Notifier`, but if the given `ctx` becomes `Done`, the notification is stopped.
Types ¶
type ContextCanceledError ¶
ContextCanceledError contains a signal to pass through when the context is cancelled.
func NewContextCanceledError ¶
func NewContextCanceledError(sig os.Signal) *ContextCanceledError
NewContextCanceledError returns a new `ContextCanceledError` instance.
func (ContextCanceledError) Error ¶
func (ContextCanceledError) Error() string
Error implements the `Error` method.
func (ContextCanceledError) Unwrap ¶
func (ContextCanceledError) Unwrap() error
Unwrap implements the `Unwrap` method.
type NotifyFunc ¶
NotifyFunc is a callback function for Notifier.