controller

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller interface {
	// Enqueue generates the key of 'obj' according to a 'KeyFunc' then adds the 'item' to queue immediately.
	Enqueue(obj interface{})

	// Run starts a certain number of concurrent workers to reconcile the items and will never stop until
	// the context is closed or canceled
	Run(ctx context.Context, workerNumber int) error
}

Controller maintains a rate limiting queue and the items in the queue will be reconciled by a "ReconcileFunc". The item will be re-queued if "ReconcileFunc" returns an error, maximum re-queue times defined by "maxRetries" above, after that the item will be discarded from the queue.

func NewController

func NewController(Name string, KeyFunc KeyFunc, ReconcileFunc ReconcileFunc, rateLimiter workqueue.RateLimiter) Controller

NewController returns a controller which can process resource periodically. We create the queue during the creation of the controller which means it can only be run once. We can move that to the run if we need to run it multiple times

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 type of the item key that stores in queue. The key could be arbitrary types.

The most common full-qualified key is of type '<namespace>/<name>' which doesn't carry the `GVK` info of the resource the key points to. We need to support a key type that includes GVK(Group Version Kind) so that we can reconcile on any type of resources.

func ClusterWideKeyFunc

func ClusterWideKeyFunc(obj interface{}) (QueueKey, error)

ClusterWideKeyFunc generates a ClusterWideKey for object.

func NamespaceKeyFunc

func NamespaceKeyFunc(obj interface{}) (QueueKey, error)

NamespaceKeyFunc generates a namespaced key for any objects.

type ReconcileFunc

type ReconcileFunc func(ctx context.Context, key QueueKey) (reconcile.Result, error)

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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