opio

package
v1.7.6 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MIT Imports: 4 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultInterruptSignals = []os.Signal{
	os.Interrupt,
	os.Kill,
	syscall.SIGTERM,
	syscall.SIGQUIT,
}

DefaultInterruptSignals is a set of default interrupt signals.

Functions

func BlockOnInterrupts

func BlockOnInterrupts(signals ...os.Signal)

BlockOnInterrupts blocks until a SIGTERM is received. Passing in signals will override the default signals.

func BlockOnInterruptsContext added in v1.2.0

func BlockOnInterruptsContext(ctx context.Context, signals ...os.Signal)

BlockOnInterruptsContext blocks until a SIGTERM is received. Passing in signals will override the default signals. The function will stop blocking if the context is closed.

func CancelOnInterrupt added in v1.4.2

func CancelOnInterrupt(ctx context.Context) context.Context

CancelOnInterrupt cancels the given context on interrupt. If a BlockFn is attached to the context, this is used as interrupt-blocking. If not, then the context blocks on a manually handled interrupt signal.

func WithBlocker added in v1.4.2

func WithBlocker(ctx context.Context, fn BlockFn) context.Context

WithBlocker overrides the interrupt blocker value, e.g. to insert a block-function for testing CLI shutdown without actual process signals.

func WithInterruptBlocker added in v1.4.2

func WithInterruptBlocker(ctx context.Context) context.Context

WithInterruptBlocker attaches an interrupt handler to the context, which continues to receive signals after every block. This helps functions block on individual consecutive interrupts.

Types

type BlockFn added in v1.4.2

type BlockFn func(ctx context.Context)

BlockFn simply blocks until the implementation of the blocker interrupts it, or till the given context is cancelled.

func BlockerFromContext added in v1.4.2

func BlockerFromContext(ctx context.Context) BlockFn

BlockerFromContext returns a BlockFn that blocks on interrupts when called.

Jump to

Keyboard shortcuts

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