v1

package
v0.0.0-...-c510420 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2022 License: MIT Imports: 15 Imported by: 1

Documentation

Overview

Package v1 provides helpers for building a stateless-action controller. It can be used to trigger an action on an observed event just once without keeping any state for retry on controller restart. The event could be from k8s or any other source. This package defines a Controller interface which provides methods required for executing an action based on an event. The action is defined using an action manager which allows targetting the action on any object, not just the event source object.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller interface {
	// GetObject fetches an instance of an object being reconciled. It can be
	// fetched from any client or cache. To keep it generic, it returns an
	// empty interface.
	GetObject(context.Context, client.ObjectKey) (interface{}, error)

	// RequireAction evaluates the target object to find out of the action must
	// be executed on it. This is where all the checks must be performed to
	// decide if an action is needed or not.
	RequireAction(context.Context, interface{}) (bool, error)

	// BuildActionManager builds an action manager that manages the actions to
	// be executed.
	BuildActionManager(interface{}) (action.Manager, error)
}

Controller is an interface that must be implemented by a stateless-action controller.

type Reconciler

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

Reconciler is the StatelessAction reconciler.

func (*Reconciler) Init

func (r *Reconciler) Init(mgr ctrl.Manager, ctrlr Controller, opts ...ReconcilerOption)

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, reterr error)

func (*Reconciler) RunAction

func (r *Reconciler) RunAction(actmgr action.Manager, o interface{}) (retErr error)

RunAction checks if an action needs to be run before running it. It also runs a deferred function at the end.

func (*Reconciler) RunActionManager

func (r *Reconciler) RunActionManager(ctx context.Context, o interface{}) error

RunActionManager runs the actions in the action manager based on the given object.

type ReconcilerOption

type ReconcilerOption func(*Reconciler)

ReconcilerOption is used to configure Reconciler.

func WithActionRetryPeriod

func WithActionRetryPeriod(duration time.Duration) ReconcilerOption

WithActionRetryPeriod sets the action retry period when it fails.

func WithActionTimeout

func WithActionTimeout(duration time.Duration) ReconcilerOption

func WithInstrumentation

func WithInstrumentation(tp trace.TracerProvider, mp metric.MeterProvider, log logr.Logger) ReconcilerOption

WithInstrumentation configures the instrumentation of the Reconciler.

func WithName

func WithName(name string) ReconcilerOption

WithName sets the name of the Reconciler.

func WithScheme

func WithScheme(scheme *runtime.Scheme) ReconcilerOption

WithScheme sets the runtime Scheme of the Reconciler.

Directories

Path Synopsis
Package action defines and interface for action Manager.
Package action defines and interface for action Manager.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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