Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Work ¶
type Work interface { // Performs the work, returning nil on success or an error. Invoked // from a goroutine. Can time out or be canceled via ctx. Run(ctx context.Context) error }
An item of work that runs in the background and may take a long time to complete. Implement this interface to support the Workers.Run() API.
type Workers ¶
type Workers struct { sync.Mutex Workers map[string]*worker // contains filtered or unexported fields }
An API for background work that triggers the reconcile control loop upon completion.
func NewWorkers ¶
func NewWorkers() *Workers
func (*Workers) Cancel ¶
Returns nil if the worker has completed or WatchPending if still in progress. Any error returned by the worker is ignored.
func (*Workers) Run ¶
Runs work in the background. Returns nil if the work completed successfully, non-nil if the work resulted in an error, or WatchPending while still in progress.
Call this from a reconcile control loop. Most likely it will return WatchPending the first time and eventually it will return success or an error. Remember to use Cancel() to clean up work that is no longer needed, like when a CRD is being deleted.
The name uniquely identifies a work invocation. If no work with the name exists then a new one will be started. If work with the name exists and is done, then it is removed so that a future call will invoke the worker again.