signals

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2023 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Send

func Send(signal os.Signal)

Send sends the specified signal to cancel a Wait

func Wait

func Wait(logger func(format string, args ...interface{}), signals ...os.Signal) chan bool

Wait sits and waits for interruption signals

The signals to listen for must be provided by the caller. Wait will always return true through the bool channel when it has caught a signal.

Example:

chanVar := signals.Wait(loggerFunc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
SetupStuff() // setting up a webserver, or w/e
<-chanVar // Wait for true to be returned because a signal was caught
TearDownStuff() // cleanup after catching a signal then exit.

Types

type Waiter

type Waiter interface {
	Send(sig os.Signal)
	Wait(logger func(string, ...interface{}), sigs ...os.Signal) chan bool
}

Waiter is a signal object used for listening for signals

func NewWaiter

func NewWaiter() Waiter

NewWaiter returns an initialized Waiter object

Jump to

Keyboard shortcuts

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