worker

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// AddRateLimited adds item to queue.
	AddRateLimited(item interface{})
	// EnqueueRateLimited generates the key for objects then adds the key as an item to queue.
	EnqueueRateLimited(obj runtime.Object)
	Run(workerNumber int, stopChan <-chan struct{})
}

Interface is a worker to process resources periodic with a rateLimitingQueue.

func New

func New(name string, interval time.Duration, keyFunc KeyFunc, reconcileFunc ReconcileFunc) Interface

New returns a workerImpl which can process resource periodic.

type KeyFunc

type KeyFunc func(obj interface{}) (QueueKey, error)

KeyFunc knows how to make a key from an object. Implementations should be deterministic.

type QueueKey

type QueueKey interface{}

QueueKey is the item key that stores in queue. The key could be arbitrary types.

In some cases, people would like store different resources in a same queue, the traditional full-qualified key, such as '<namespace>/<name>', can't distinguish which resource the key belongs to, the key might carry more information of a resource, such as GVK(Group Version Kind), in that cases people need to use self-defined key, e.g. a struct.

type ReconcileFunc

type ReconcileFunc func(key QueueKey) error

ReconcileFunc knows how to consume items(key) from the queue.

Jump to

Keyboard shortcuts

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