signals

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Manual added in v1.3.0

func Manual()

Manual trigger for action execution.

Note that this will have no effect in case a signal has already been detected.

func OnSignal

func OnSignal(action func(os.Signal))

OnSignal accepts an action function that will be executed whenever a signal is detected. It can be called multiple times to add more functions. The action functions will be called concurrently.

func Wait

func Wait()

Wait blocks until all actions have been executed.

Types

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

Listener listens to signals and allows actions to be called whenever a signal is received.

func NewListener

func NewListener(sigs ...os.Signal) *Listener

NewListener creates a new Listener instance with the given signals.

func (*Listener) Manual added in v1.3.0

func (l *Listener) Manual()

Manual trigger for action execution. This can be deferred in the main function to run cleanup actions even if no interruptions are detected.

Note that this will have no effect in case a signal has already been detected.

func (*Listener) OnSignal

func (l *Listener) OnSignal(action func(os.Signal))

OnSignal accepts an action function that will be executed whenever a signal is detected. It can be called multiple times to add more functions. The action functions will be called concurrently.

func (*Listener) Wait

func (l *Listener) Wait()

Wait blocks until all actions have been executed.

The listener instance is no longer usable once this method is called.

Jump to

Keyboard shortcuts

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