controller

package
v0.0.0-...-2393416 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start

func Start(controllers ...Reconciler) (err error)

Start starts one or multiple controllers. If initial sync is required, use StartWithInitialSync

func StartWithInitialSync

func StartWithInitialSync(initialSync func() error, controllers ...Reconciler) (err error)

StartWithInitialSync starts one or multiple controllers that share initialSync function. initialSync will be called after all event handlers for given controllers were added to the informer (if any), but before queue handlers are started. It ensures no events will be missed. A user of this package that manages multiple controllers would most likely do a single call to this function if it needs to use this sync to take an initial action (i.e. building up its own cache) correlating the information from all the initialized informers. If initial sync is not required, use Start.

func Stop

func Stop(controllers ...Reconciler)

Types

type Controller

type Controller interface {
	Reconciler
	ReconcileAll()
}

Controller is a level-driven controller that is fed of items to reconcile through a provided informer

func NewController

func NewController[T any](name string, config *ControllerConfig[T]) Controller

NewController creates a new level-driven controller. It should be started and stopped using Start/StartWithInitialSync/Stop functions.

type ControllerConfig

type ControllerConfig[T any] struct {
	RateLimiter workqueue.TypedRateLimiter[string]
	Reconcile   func(key string) error
	// How many workers should be started for this controller.
	Threadiness int
	Informer    cache.SharedIndexInformer
	Lister      func(selector labels.Selector) (ret []*T, err error)
	// ObjNeedsUpdate tells if object should be reconciled.
	// May be called with oldObj = nil on Add, won't be called on Delete.
	ObjNeedsUpdate func(oldObj, newObj *T) bool
}

type Reconciler

type Reconciler interface {
	Reconcile(key string)
	ReconcileAfter(key string, duration time.Duration)
	// contains filtered or unexported methods
}

Reconciler is a basic level-driven controller that is fed externally of items to reconcile through its Reconcile method

func NewReconciler

func NewReconciler(name string, config *ReconcilerConfig) Reconciler

NewReconciler creates a new basic level-driven controller. It should be started and stopped using Start/StartWithInitialSync/Stop functions.

type ReconcilerConfig

type ReconcilerConfig struct {
	RateLimiter workqueue.TypedRateLimiter[string]
	Reconcile   func(key string) error
	// How many workers should be started for this reconciler.
	Threadiness int
}

Jump to

Keyboard shortcuts

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