workers

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

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

func (w *Workers) Cancel(name string) error

Returns nil if the worker has completed or WatchPending if still in progress. Any error returned by the worker is ignored.

func (*Workers) Run

func (w *Workers) Run(name string, object client.Object, work Work) error

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.

func (*Workers) SetUpReconciler

func (w *Workers) SetUpReconciler(builder *builder.Builder)

Jump to

Keyboard shortcuts

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