Documentation ¶
Overview ¶
Package syncs provides synchronization primitives util functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Go ¶
Go is a basic promise implementation: it wraps calls a function in a goroutine and returns a channel which will later return the function's return value.
func SignalHandler ¶
func SignalHandler(ctx context.Context, signals ...os.Signal) (execute func() error, interrupt func(error))
SignalHandler returns an actor, i.e. an execute and interrupt func, that terminates with SignalError when the process receives one of the provided signals, or the parent context is canceled.
func WaitCloseSignals ¶
WaitCloseSignals for some huang program.
Usage:
// do something. eg: start a http server syncs.WaitCloseSignals(func(sig os.Signal) { // do something })
Types ¶
type ErrGroup ¶ added in v0.6.13
ErrGroup is a collection of goroutines working on subtasks that are part of the same overall task.
Refers:
https://github.com/neilotoole/errgroup https://github.com/fatih/semgroup
func NewCtxErrGroup ¶ added in v0.6.13
NewCtxErrGroup instance
type SignalError ¶
SignalError is returned by the signal handler's execute function when it terminates due to a received signal.
func (SignalError) Error ¶
func (e SignalError) Error() string
Error implements the error interface.