Documentation ¶
Overview ¶
Package signalwrapper is used to run functions that are sensitive to signals that may be received from outside the process. It can also be used as just an async function runner that is cancellable and we may abstract this further into another package in the future.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CancellableFunc ¶
type CancellableFunc func(<-chan struct{}) error
CancellableFunc is a function that cancels if it receives a message on the given channel. It must return an error if any occurred. It should return no error if it was cancelled successfully since it is assumed that this function will probably be called again at some future point since it was interrupted.
type Wrapped ¶
type Wrapped struct { // ErrCh is the channel to listen for real-time events on the wrapped // function. A nil error sent means the execution completed without error. // This is an exactly once delivery channel. ErrCh <-chan error // contains filtered or unexported fields }
Wrapped is the return value of wrapping a function. This has channels that can be used to wait for a result as well as functions to help with different behaviors.
func Run ¶
func Run(f CancellableFunc) *Wrapped
Run wraps and runs the given cancellable function and returns the Wrapped struct that can be used to listen for events, cancel on other events (such as timeouts), etc.