controller

package
v0.0.0-...-87ef7df Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	// contains filtered or unexported fields
}

Base implements basic functions for controllers.

func NewControllerBase

func NewControllerBase() Base

NewControllerBase returns new Base.

func (*Base) AddHook

func (c *Base) AddHook(hook Hook) error

AddHook adds a new hook to the controller.

func (*Base) GetHooks

func (c *Base) GetHooks() []Hook

GetHooks returns hooks registered in the controller

func (*Base) RemoveHook

func (c *Base) RemoveHook(hook Hook) error

RemoveHook removes given hook from the controller.

type Controller

type Controller interface {
	// Run starts the controller listening on custom resource changes.
	Run(ctx context.Context) error
	// AddHook allows to inject new hook into the controller.
	AddHook(hook Hook) error
	// RemoveHook removes hook from the controller.
	RemoveHook(hook Hook) error
}

Controller is base type for all custom resource controllers.

type Event

type Event struct {
	Type   EventType
	Object interface{}
}

Event represents event processed by the controller.

type EventType

type EventType int

EventType represents type of a Event.

const (
	EventAdded EventType = iota
	EventUpdated
	EventDeleted
)

Available Event types.

type EventsHook

type EventsHook interface {
	Hook
	GetEventsChan() <-chan Event
}

EventsHook extends `Hook`. All processed events are published to the events channel.

func NewEventsHook

func NewEventsHook(channelSize int) EventsHook

NewEventsHook returns a new EventsHook with channel with the capacity of channelSize.

type Hook

type Hook interface {
	// OnAdd runs after the controller finishes processing the added object.
	OnAdd(object interface{})
	// OnUpdate runs after the controller finishes processing the updated object.
	OnUpdate(object interface{})
	// OnDelete runs after the controller finishes processing the deleted object.
	OnDelete(object interface{})
}

Hook represents actions that can be injected into the controller.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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