Documentation ¶
Overview ¶
Package signal is a wrapper over the os/signal package that allows multiple handlers to respond to an exit signal, and blocks until that exit signal is received.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExitListener ¶
type ExitListener interface { AddHandler(Handler) Listen() chan struct{} }
ExitListener listens for exit signals, and responds by invoking any handlers that have been added. It start listening until Wait() in invoked, at which point it will block until it receives any exit signal, call the handlers in the order they were added, and then stop listening.
func NewExitListener ¶
func NewExitListener() ExitListener
NewExitListener creates a new instance of ExitListener. Clients are responsible for adding handlers and calling Wait() to kick it off.
func NewExitListenerWithOptions ¶ added in v1.3.0
func NewExitListenerWithOptions(signals ...os.Signal) ExitListener
NewExitListenerWithOptions creates a new instance of ExitListener with configurable options. Clients are responsible for adding handlers to the listener which can then be waited on by `Wait()`ing.