controller

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: MPL-2.0 Imports: 4 Imported by: 3

Documentation

Overview

Package controller defines common interfaces to be implemented by the controllers and controller runtime.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller interface {
	Name() string
	Inputs() []Input
	Outputs() []Output

	Run(context.Context, Runtime, *zap.Logger) error
}

Controller interface should be implemented by Controllers.

type DependencyEdge

type DependencyEdge struct {
	ControllerName string

	ResourceNamespace resource.Namespace
	ResourceType      resource.Type
	ResourceID        resource.ID

	EdgeType DependencyEdgeType
}

DependencyEdge represents relationship between controller and resource(s).

type DependencyEdgeType

type DependencyEdgeType int

DependencyEdgeType is edge type in controller graph.

const (
	EdgeOutputExclusive DependencyEdgeType = iota
	EdgeOutputShared
	EdgeInputStrong
	EdgeInputWeak
	EdgeInputDestroyReady
)

Controller graph edge types.

type DependencyGraph

type DependencyGraph struct {
	Edges []DependencyEdge
}

DependencyGraph is the exported information about controller/resources dependencies.

type Engine

type Engine interface {
	// RegisterController registers new controller.
	RegisterController(ctrl Controller) error
	// Run the controllers.
	Run(ctx context.Context) error
}

Engine is the entrypoint into Controller Runtime.

type Input

type Input struct {
	ID        *resource.ID
	Namespace resource.Namespace
	Type      resource.Type
	Kind      InputKind
}

Input of the controller (dependency on some resource(s)).

Each controller might have multiple inputs, it might depend on all the objects of some type under namespace, or on specific object by ID.

Input might be either Weak or Strong. Any kind of input triggers cascading reconcile on changes, Strong dependencies in addition block deletion of parent object until all the dependencies are torn down.

Input can also be "DestroyReady" which means that the controller is watching some of its outputs to be ready to be destroyed. Controller will be notified when the resource enters "teardown" phase and has no finalizers attached. Resources are filtered to be owned by the controller.

type InputKind

type InputKind = int

InputKind for inputs.

const (
	InputWeak InputKind = iota
	InputStrong
	InputDestroyReady
)

Input kinds.

type Option added in v0.3.1

type Option func(*Options)

Option for operation.

func WithOwner added in v0.3.1

func WithOwner(owner string) Option

WithOwner allows to specify owner of the resource.

type Options added in v0.3.1

type Options struct {
	Owner *string
}

Options for operation.

func ToOptions added in v0.3.1

func ToOptions(opts ...Option) Options

ToOptions converts variadic options to Options.

type Output

type Output struct {
	Type resource.Type
	Kind OutputKind
}

Output of the controller.

Controller can only modify resources which are declared as outputs.

type OutputKind

type OutputKind = int

OutputKind for outputs.

const (
	OutputExclusive OutputKind = iota
	OutputShared
)

Output kinds.

type OutputTracker added in v0.3.1

type OutputTracker interface {
	StartTrackingOutputs()
	CleanupOutputs(ctx context.Context, outputs ...resource.Kind) error
}

OutputTracker provides automatic cleanup of the outputs based on the calls to Modify function.

OutputTracker is optional, it is enabled by calling StartTrackingOutputs at the beginning of the reconcile cycle. Every call to Modify will be tracked and the outputs which are not touched will be destroyed. Finalize the cleanup by calling CleanupOutputs at the end of the reconcile cycle, it also automatically calls ResetRestartBackoff.

CleanupOutputs doesn't support finalizers on output resources.

type Reader

Reader provides read-only access to the state.

state.State also satisfies this interface.

type ReaderWriter added in v0.3.0

type ReaderWriter interface {
	Reader
	Writer
}

ReaderWriter combines Reader and Writer interfaces.

type ReconcileEvent

type ReconcileEvent struct{}

ReconcileEvent is a signal for controller to reconcile its resources.

type Runtime

type Runtime interface {
	EventCh() <-chan ReconcileEvent
	QueueReconcile()
	ResetRestartBackoff()

	UpdateInputs([]Input) error

	Reader
	Writer
	OutputTracker
}

Runtime interface as presented to the controller.

type Writer

Writer provides write access to the state.

Only output objects can be written to by the controller.

Directories

Path Synopsis
Package conformance implements tests which verify conformance of the implementation with the spec.
Package conformance implements tests which verify conformance of the implementation with the spec.
Package generic provides implementations of generic controllers.
Package generic provides implementations of generic controllers.
cleanup
Package cleanup provides a generic implementation of controller which waits for and cleans up resources.
Package cleanup provides a generic implementation of controller which waits for and cleans up resources.
transform
Package transform provides a generic implementation of controller which transforms resources A into resources B.
Package transform provides a generic implementation of controller which transforms resources A into resources B.
Package protobuf provides wrappers/adapters between gRPC service and runtime.Engine.
Package protobuf provides wrappers/adapters between gRPC service and runtime.Engine.
client
Package client provides a wrapper around gRPC Runtime client to present it as controller.Engine interface.
Package client provides a wrapper around gRPC Runtime client to present it as controller.Engine interface.
server
Package server provides a wrapper around controller.Runtime over gRPC.
Package server provides a wrapper around controller.Runtime over gRPC.
Package runtime implements the controller runtime.
Package runtime implements the controller runtime.
dependency
Package dependency implements the dependency handling database.
Package dependency implements the dependency handling database.

Jump to

Keyboard shortcuts

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