sigctx

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: MIT Imports: 4 Imported by: 0

README

pipeline status coverage report Latest Release

Signal Aware Context

This package provides a helper function for Go contexts that get canceled if a specific OS signal is received.

Usage

Import git.prolicht.digital/golib/sigctx. After that you can use the API functions, for example:

ctx := sigctx.New(syscall.SIGHUP)
<-ctx.Done() // this context gets canceled once the SIGHUP signal is received
ctx := sigctx.FromContext(parentCtx, syscall.SIGHUP)
<-ctx.Done() // this context gets canceled once the SIGHUP signal is received or the parent context gets canceled

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context, sig ...os.Signal) context.Context

FromContext returns a context that gets closed once a given signal is retrieved. By default, the following signals are handled: syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP

func New

func New(sig ...os.Signal) context.Context

New returns a context that gets closed once a given signal is retrieved. By default, the following signals are handled: syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP

Types

This section is empty.

Jump to

Keyboard shortcuts

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