fsm

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder[T any, Obj apitypes.FSMResource[T]] struct {
	// contains filtered or unexported fields
}

Builder is a builder for an FSM controller.

func NewBuilder

func NewBuilder[T any, Obj apitypes.FSMResource[T]](
	obj Obj,
	initialState *fsmtypes.State[Obj],
	scheme *runtime.Scheme,
) *Builder[T, Obj]

NewBuilder returns a builder that builds a function wiring up a logical FSM controller to a manager. Obj is the object being reconciled and initialState is the initial state in the finite state machine,

func (*Builder[T, Obj]) Build

func (b *Builder[T, Obj]) Build() SetupFunc

func (*Builder[T, Obj]) Manages

func (b *Builder[T, Obj]) Manages(
	gvks ...schema.GroupVersionKind,
) *Builder[T, Obj]

Manages adds a managed resource type to the controller. All resource types that the controller manages must be included.

func (*Builder[T, Obj]) Watches

func (b *Builder[T, Obj]) Watches(
	object client.Object,
	handler handler.EventHandler,
	triggerType fsmhandler.TriggerType,
	opts ...ctrlbuilder.WatchesOption,
) *Builder[T, Obj]

Watches adds a custom watch to the controller.

func (*Builder[T, Obj]) WatchesRawSource

func (b *Builder[T, Obj]) WatchesRawSource(
	src source.Source,
	handler handler.EventHandler,
	triggerType fsmhandler.TriggerType,
	opts ...ctrlbuilder.WatchesOption,
) *Builder[T, Obj]

WatchesRawSource adds a custom raw source watch to the controller. Prefer using `Watches(...)` unless you need controller-runtime's lower level API.

func (*Builder[T, Obj]) WithControllerHandle

func (b *Builder[T, Obj]) WithControllerHandle(fn ControllerFunc) *Builder[T, Obj]

WithControllerHandle adds a ControllerFunc.

func (*Builder[T, Obj]) WithEventFilter

func (b *Builder[T, Obj]) WithEventFilter(
	predicate predicate.Predicate,
) *Builder[T, Obj]

WithEventFilter adds a custom event filter to the controller.

func (*Builder[T, Obj]) WithFinalizerState

func (b *Builder[T, Obj]) WithFinalizerState(state *fsmtypes.State[Obj]) *Builder[T, Obj]

WithFinalizerState adds an optional finalizer state, guaranteed to be executed after a deletion has been issued for the object and before the object is deleted from kubernetes.

func (*Builder[T, Obj]) WithMaxConcurrentReconciles

func (b *Builder[T, Obj]) WithMaxConcurrentReconciles(maxConcurrentReconciles int) *Builder[T, Obj]

WithMaxConcurrentReconciles sets the maxConcurrentReconciles option for controller-runtime. Defaults to 1 if not specified or when a value <= 0 is passed. controller-runtime ensures a single object is not reconciled by multiple reconcilers concurrently. If your controller manages global state (e.g. caches attached to the controller struct), you need to ensure it is thread safe before increasing the concurrency.

func (*Builder[T, Obj]) WithReconcilerOptions

func (b *Builder[T, Obj]) WithReconcilerOptions(reconcilerOptions fsmtypes.ReconcilerOptions[T, Obj]) *Builder[T, Obj]

WithReconcilerOptions sets reconciler options.

type ClaimBuilder

type ClaimBuilder[T any, U any, ClaimedType apitypes.ClaimedType[T], ClaimType apitypes.ClaimType[U]] struct {
	// contains filtered or unexported fields
}

ClaimBuilder is a builder for an FSM controller managing a pair of claimed and claim resources.

func NewClaimBuilder

func NewClaimBuilder[T any, U any, ClaimedType apitypes.ClaimedType[T], ClaimType apitypes.ClaimType[U]](
	obj ClaimedType,
	claim ClaimType,
	initialState *types.State[ClaimedType],
	scheme *runtime.Scheme,
) *ClaimBuilder[T, U, ClaimedType, ClaimType]

NewClaimBuilder returns a builder that builds a function wiring up a logical FSM controller to a manager. Obj is the object being reconciled and initialState is the initial state in the finite state machine,

func (*ClaimBuilder[T, U, ClaimedType, ClaimType]) BeforeDelete

func (b *ClaimBuilder[T, U, ClaimedType, ClaimType]) BeforeDelete(
	beforeDelete internal.BeforeDelete[T, ClaimedType, U, ClaimType],
) *ClaimBuilder[T, U, ClaimedType, ClaimType]

BeforeDelete adds a hook to perform custom actions before claimed resource is deleted. Claimed resource won't be deleted as long as hook returns error.

func (*ClaimBuilder[T, U, ClaimedType, ClaimType]) Build

func (b *ClaimBuilder[T, U, ClaimedType, ClaimType]) Build() SetupFunc

func (*ClaimBuilder[T, U, ClaimedType, ClaimType]) Manages

func (b *ClaimBuilder[T, U, ClaimedType, ClaimType]) Manages(
	gvks ...schema.GroupVersionKind,
) *ClaimBuilder[T, U, ClaimedType, ClaimType]

Manages adds a managed resource type to the controller. All resource types that the controller manages must be included.

func (*ClaimBuilder[T, U, ClaimedType, ClaimType]) Watches

func (b *ClaimBuilder[T, U, ClaimedType, ClaimType]) Watches(
	object client.Object,
	handler handler.EventHandler,
	triggerType fsmhandler.TriggerType,
	opts ...ctrlbuilder.WatchesOption,
) *ClaimBuilder[T, U, ClaimedType, ClaimType]

Watches adds a custom watch to the controller.

func (*ClaimBuilder[T, U, ClaimedType, ClaimType]) WatchesRawSource

func (b *ClaimBuilder[T, U, ClaimedType, ClaimType]) WatchesRawSource(
	src source.Source,
	handler handler.EventHandler,
	triggerType fsmhandler.TriggerType,
	opts ...ctrlbuilder.WatchesOption,
) *ClaimBuilder[T, U, ClaimedType, ClaimType]

WatchesRawSource adds a custom raw source watch to the controller. Prefer using `Watches(...)` unless you need controller-runtime's lower level API.

func (*ClaimBuilder[T, U, ClaimedType, ClaimType]) WithControllerHandle

func (b *ClaimBuilder[T, U, ClaimedType, ClaimType]) WithControllerHandle(fn ControllerFunc) *ClaimBuilder[T, U, ClaimedType, ClaimType]

WithControllerHandle adds a ControllerFunc.

func (*ClaimBuilder[T, U, ClaimedType, ClaimType]) WithEventFilter

func (b *ClaimBuilder[T, U, ClaimedType, ClaimType]) WithEventFilter(
	predicate predicate.Predicate,
) *ClaimBuilder[T, U, ClaimedType, ClaimType]

WithEventFilter adds a custom event filter to the controller.

func (*ClaimBuilder[T, U, ClaimedType, ClaimType]) WithFinalizerState

func (b *ClaimBuilder[T, U, ClaimedType, ClaimType]) WithFinalizerState(state *types.State[ClaimedType]) *ClaimBuilder[T, U, ClaimedType, ClaimType]

WithFinalizerState adds an optional finalizer state, guaranteed to be executed after a deletion has been issued for the object and before the object is deleted from kubernetes.

func (*ClaimBuilder[T, U, ClaimedType, ClaimType]) WithMaxConcurrentReconciles

func (b *ClaimBuilder[T, U, ClaimedType, ClaimType]) WithMaxConcurrentReconciles(maxConcurrentReconciles int) *ClaimBuilder[T, U, ClaimedType, ClaimType]

WithMaxConcurrentReconciles sets the maxConcurrentReconciles option for controller-runtime. Defaults to 1 if not specified or when a value <= 0 is passed. controller-runtime ensures a single object is not reconciled by multiple reconcilers concurrently. If your controller manages global state (e.g. caches attached to the controller struct), you need to ensure it is thread safe before increasing the concurrency.

type ControllerFunc

type ControllerFunc func(controller.Controller)

ControllerFunc is a function with a handle to a controller.Controller. Typically used in cases where watches need to be initiated dynamically at run time.

type SetupFunc

SetupFunc wires up the provided reconciler with the controller-runtime manager and other common dependencies.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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