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: 13 Imported by: 2

Documentation

Overview

Package v1 provides helpers to build a sync controller. It defines a Controller interface which provides methods required for reconciling a sync controller. The package also provides an implementation of the Reconcile method that can be embedded in a controller to satisfy the controller-runtime's Reconciler interface. It supports plugging in sync functions that run as go routines and help with keeping the systems in sync.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller interface {
	// Ensure receives a k8s object and calls an external system's API to
	// ensure an associated object exists in the external system. Based on the
	// use case, it may also update the object in the external system to have
	// the same the desired configuration.
	Ensure(context.Context, client.Object) error

	// Delete receives a k8s object that's deleted and calls an external
	// system's API to delete the associated object in the external system.
	Delete(context.Context, client.Object) error
}

Controller is an object sync controller interface that must be implemented by an object sync controller. It provides methods required for reconciling and syncing objects.

type Reconciler

type Reconciler struct {
	Name          string
	Ctrlr         Controller
	Prototype     client.Object
	PrototypeList client.ObjectList
	Client        client.Client
	Scheme        *runtime.Scheme
	SyncFuncs     []SyncFunc
	Inst          *telemetry.Instrumentation
}

Reconciler defines a sync reconciler.

func (*Reconciler) Init

func (s *Reconciler) Init(mgr ctrl.Manager, ctrlr Controller, prototype client.Object, prototypeList client.ObjectList, opts ...ReconcilerOption) error

Init initializes the Reconciler for a given Object with the given options.

func (*Reconciler) Reconcile

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

func (*Reconciler) RunSyncFuncs

func (s *Reconciler) RunSyncFuncs()

RunSyncFuncs runs all the SyncFuncs in go routines.

type ReconcilerOption

type ReconcilerOption func(*Reconciler)

ReconcilerOption is used to configure Reconciler.

func WithClient

func WithClient(cli client.Client) ReconcilerOption

WithClient sets the k8s client in the reconciler.

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 WithPrototype

func WithPrototype(obj client.Object) ReconcilerOption

WithPrototype sets a prototype of the object that's reconciled.

func WithScheme

func WithScheme(scheme *runtime.Scheme) ReconcilerOption

WithScheme sets the runtime Scheme of the Reconciler.

func WithSyncFuncs

func WithSyncFuncs(sf []SyncFunc) ReconcilerOption

WithSyncFuncs sets the syncFuncs of the Reconciler.

type SyncFunc

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

SyncFunc defines a sync function with a sync period.

func NewSyncFunc

func NewSyncFunc(f func(), p time.Duration, d time.Duration) SyncFunc

NewSyncFunc returns a new SyncFunc, given a function and a sync period.

func (SyncFunc) Call

func (sf SyncFunc) Call()

Call calls the SyncFunc function.

func (SyncFunc) Run

func (sf SyncFunc) Run()

Run runs the SyncFunc function at the SyncFunc period.

Directories

Path Synopsis
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