Documentation ¶
Overview ¶
Package sigctx were developed to easily bind signals and context.Context. For example, When receive a signal, you can notify received signals to all goroutines using context. Or when you receive a signal, you can invoke a context cancel.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Canceled = errors.New("signal received")
Canceled is the error returned by Context.Err when the context is canceled.
Functions ¶
func Recv ¶
Recv send channel when a process receives a signal.
You can use Recv(ctx) only if you pass a signalCtx context as an argument. If you want to use Recv(ctx) please wrap context.Context so that the signalCtx context is the last.
func Signal ¶
Signal returns os.Signal and error.
If the context passed to the argument is a signalCtx context, it returns the received os.Signal. Otherwise it returns nil and error message.
func WithCancelSignals ¶
WithCancelSignals returns a copy of parent which the value can context cancel by signals.
Context cancellation is executed after receiving the signal.
func WithSignals ¶
WithSignals returns a copy of parent which the value can notify signals by Recv(ctx).
When the process receive signals passed to the argument, it sends the information of the received signal to all the goroutines.
Types ¶
This section is empty.