signal

package
v1.7.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

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.

type Handler

type Handler func()

Handler is a simply a function intended to be called in response to a signal.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL