Documentation ¶
Index ¶
- Variables
- func BlockOnInterrupts(signals ...os.Signal)
- func BlockOnInterruptsContext(ctx context.Context, signals ...os.Signal)
- func CancelOnInterrupt(ctx context.Context) context.Context
- func WithBlocker(ctx context.Context, fn BlockFn) context.Context
- func WithInterruptBlocker(ctx context.Context) context.Context
- type BlockFn
Constants ¶
This section is empty.
Variables ¶
var DefaultInterruptSignals = []os.Signal{ os.Interrupt, os.Kill, syscall.SIGTERM, syscall.SIGQUIT, }
DefaultInterruptSignals is a set of default interrupt signals.
Functions ¶
func BlockOnInterrupts ¶
BlockOnInterrupts blocks until a SIGTERM is received. Passing in signals will override the default signals.
func BlockOnInterruptsContext ¶ added in v1.2.0
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
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
WithBlocker overrides the interrupt blocker value, e.g. to insert a block-function for testing CLI shutdown without actual process signals.
Types ¶
type BlockFn ¶ added in v1.4.2
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
BlockerFromContext returns a BlockFn that blocks on interrupts when called.