Documentation ¶
Overview ¶
Package simplesignalhandler provides a worker that responds to os signals and returns a pre-defined error from this worker when the signal is received.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Manifold ¶
func Manifold(config ManifoldConfig) dependency.Manifold
Manifold returns the dependency manifold for this worker based on the config provided.
Types ¶
type ManifoldConfig ¶
type ManifoldConfig struct { // SignalCh is a preconfigured channel listening for signals. SignalCh <-chan os.Signal // DefaultHandlerError is the default error to return from this worker when // there is no mapping for the received signal. Value must be specified. DefaultHandlerError error // HandlerErrors is a map of os.Signal to error returns from this worker. // Valid for this map to be nil or empty. HandlerErrors map[os.Signal]error // Logger to use for this worker Logger logger.Logger }
ManifoldConfig is responsible for configuring this worker.
func (ManifoldConfig) Start ¶
func (m ManifoldConfig) Start(context context.Context, getter dependency.Getter) (worker.Worker, error)
Start is responsible for creating a new worker for the manifold config.
func (ManifoldConfig) Validate ¶
func (m ManifoldConfig) Validate() error
Validate validates the manifold config.
type SignalHandlerFunc ¶
SignalHandlerFunc is func definition for returning an error based on a received signal.
func SignalHandler ¶
func SignalHandler(defaultErr error, signalMap map[os.Signal]error) SignalHandlerFunc
SignalHandler is a default implementation that uses signal mapping and a default error.
type SignalWatcher ¶
type SignalWatcher struct {
// contains filtered or unexported fields
}
SignalWatcher is the worker responsible for watching signals and returning the appropriate error from a handler.
func NewSignalWatcher ¶
func NewSignalWatcher( logger logger.Logger, sig <-chan os.Signal, handler SignalHandlerFunc, ) (*SignalWatcher, error)
NewSignalWatcher constructs a new signal watcher worker with the specified signal channel and handler func.