controller

package
v0.0.0-...-f1c87f1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter(gvk schema.GroupVersionKind) func(obj interface{}) bool

Filter makes it simple to create FilterFunc's for use with cache.FilteringResourceEventHandler that filter based on the schema.GroupVersionKind of the controlling resources.

func PassNew

func PassNew(f func(interface{})) func(interface{}, interface{})

PassNew makes it simple to create an UpdateFunc for use with cache.ResourceEventHandlerFuncs that can delegate the same methods as AddFunc/DeleteFunc but passing through only the second argument (which is the "new" object).

Types

type Impl

type Impl struct {
	// Reconciler is the workhorse of this controller, it is fed the keys
	// from the workqueue to process.  Public for testing.
	Reconciler Reconciler

	// WorkQueue is a rate limited work queue. This is used to queue work to be
	// processed instead of performing it as soon as a change happens. This
	// means we can ensure we only process a fixed amount of resources at a
	// time, and makes it easy to ensure we are never processing the same item
	// simultaneously in two different workers.
	WorkQueue workqueue.RateLimitingInterface
	// contains filtered or unexported fields
}

Impl is our core controller implementation. It handles queuing and feeding work from the queue to an implementation of Reconciler.

func NewImpl

func NewImpl(r Reconciler, logger *zap.SugaredLogger, workQueueName string) *Impl

NewImpl instantiates an instance of our controller that will feed work to the provided Reconciler as it is enqueued.

func (*Impl) Enqueue

func (c *Impl) Enqueue(obj interface{})

Enqueue takes a resource, converts it into a namespace/name string, and passes it to EnqueueKey.

func (*Impl) EnqueueControllerOf

func (c *Impl) EnqueueControllerOf(obj interface{})

EnqueueControllerOf takes a resource, identifies its controller resource, converts it into a namespace/name string, and passes that to EnqueueKey.

func (*Impl) EnqueueKey

func (c *Impl) EnqueueKey(key string)

EnqueueKey takes a namespace/name string and puts it onto the work queue.

func (*Impl) Run

func (c *Impl) Run(threadiness int, stopCh <-chan struct{}) error

Run starts the controller's worker threads, the number of which is threadiness. It then blocks until stopCh is closed, at which point it shuts down its internal work queue and waits for workers to finish processing their current work items.

type Reconciler

type Reconciler interface {
	Reconcile(ctx context.Context, key string) error
}

Reconciler is the interface that controller implementations are expected to implement, so that the shared controller.Impl can drive work through it.

Jump to

Keyboard shortcuts

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