handler

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnqueueRequestForObject

type EnqueueRequestForObject struct{}

EnqueueRequestForObject enqueues a Request containing the Name and Namespace of the object that is the source of the Event. (e.g. the created / deleted / updated objects Name and Namespace). handler.EnqueueRequestForObject is used by almost all Controllers that have associated Resources (e.g. CRDs) to reconcile the associated Resource.

func (*EnqueueRequestForObject) Create

Create implements EventHandler.

func (*EnqueueRequestForObject) Delete

Delete implements EventHandler.

func (*EnqueueRequestForObject) Generic

Generic implements EventHandler.

func (*EnqueueRequestForObject) Update

Update implements EventHandler.

type EnqueueRequestForOwner

type EnqueueRequestForOwner struct {
	// OwnerType is the type of the Owner object to look for in OwnerReferences.  Only Group and Kind are compared.
	OwnerType runtime.Object

	// IsController if set will only look at the first OwnerReference with Controller: true.
	IsController bool
	// contains filtered or unexported fields
}

EnqueueRequestForOwner enqueues Requests for the Owners of an object. E.g. the object that created the object that was the source of the Event.

If a ReplicaSet creates Pods, users may reconcile the ReplicaSet in response to Pod Events using:

- a source.Kind Source with Type of Pod.

- a handler.EnqueueRequestForOwner EventHandler with an OwnerType of ReplicaSet and IsController set to true.

func (*EnqueueRequestForOwner) Create

Create implements EventHandler.

func (*EnqueueRequestForOwner) Delete

Delete implements EventHandler.

func (*EnqueueRequestForOwner) Generic

Generic implements EventHandler.

func (*EnqueueRequestForOwner) Update

Update implements EventHandler.

type EventHandler

type EventHandler interface {
	// Create is called in response to an create event - e.g. Pod Creation.
	Create(event.CreateEvent, workqueue.RateLimitingInterface)

	// Update is called in response to an update event -  e.g. Pod Updated.
	Update(event.UpdateEvent, workqueue.RateLimitingInterface)

	// Delete is called in response to a delete event - e.g. Pod Deleted.
	Delete(event.DeleteEvent, workqueue.RateLimitingInterface)

	// Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or
	// external trigger request - e.g. reconcile Autoscaling, or a Webhook.
	Generic(event.GenericEvent, workqueue.RateLimitingInterface)
}

EventHandler enqueues reconcile.Requests in response to events (e.g. Pod Create). EventHandlers map an Event for one object to trigger Reconciles for either the same object or different objects - e.g. if there is an Event for object with type Foo (using source.KindSource) then reconcile one or more object(s) with type Bar.

Identical reconcile.Requests will be batched together through the queuing mechanism before reconcile is called.

* Use EnqueueRequestForObject to reconcile the object the event is for - do this for events for the type the Controller Reconciles. (e.g. Deployment for a Deployment Controller)

* Use EnqueueRequestForOwner to reconcile the owner of the object the event is for - do this for events for the types the Controller creates. (e.g. ReplicaSets created by a Deployment Controller)

* Use EnqueueRequestsFromMapFunc to transform an event for an object to a reconcile of an object of a different type - do this for events for types the Controller may be interested in, but doesn't create. (e.g. If Foo responds to cluster size events, map Node events to Foo objects.)

Unless you are implementing your own EventHandler, you can ignore the functions on the EventHandler interface. Most users shouldn't need to implement their own EventHandler.

func EnqueueRequestsFromMapFunc

func EnqueueRequestsFromMapFunc(fn MapFunc) EventHandler

EnqueueRequestsFromMapFunc enqueues Requests by running a transformation function that outputs a collection of reconcile.Requests on each Event. The reconcile.Requests may be for an arbitrary set of objects defined by some user specified transformation of the source Event. (e.g. trigger Reconciler for a set of objects in response to a cluster resize event caused by adding or deleting a Node)

EnqueueRequestsFromMapFunc is frequently used to fan-out updates from one object to one or more other objects of a differing type.

For UpdateEvents which contain both a new and old object, the transformation function is run on both objects and both sets of Requests are enqueue.

type Funcs

type Funcs struct {
	// Create is called in response to an add event.  Defaults to no-op.
	// RateLimitingInterface is used to enqueue reconcile.Requests.
	CreateFunc func(event.CreateEvent, workqueue.RateLimitingInterface)

	// Update is called in response to an update event.  Defaults to no-op.
	// RateLimitingInterface is used to enqueue reconcile.Requests.
	UpdateFunc func(event.UpdateEvent, workqueue.RateLimitingInterface)

	// Delete is called in response to a delete event.  Defaults to no-op.
	// RateLimitingInterface is used to enqueue reconcile.Requests.
	DeleteFunc func(event.DeleteEvent, workqueue.RateLimitingInterface)

	// GenericFunc is called in response to a generic event.  Defaults to no-op.
	// RateLimitingInterface is used to enqueue reconcile.Requests.
	GenericFunc func(event.GenericEvent, workqueue.RateLimitingInterface)
}

Funcs implements EventHandler.

func (Funcs) Create

Create implements EventHandler.

func (Funcs) Delete

Delete implements EventHandler.

func (Funcs) Generic

Generic implements EventHandler.

func (Funcs) Update

Update implements EventHandler.

type MapFunc

type MapFunc func(client.Object) []reconcile.Request

MapFunc is the signature required for enqueueing requests from a generic function. This type is usually used with EnqueueRequestsFromMapFunc when registering an event handler.

Jump to

Keyboard shortcuts

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