reconciler

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package reconciler contains a common interface for gNMI reconciler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder simplifies the creation of reconcilers and reduces some of the required boilerplate.

func NewBuilder

func NewBuilder(id string) *Builder

NewBuilder creates a new reconciler builder.

func (*Builder) Build

func (b *Builder) Build() *BuiltReconciler

Build returns the reconciler as configuration and resets the builder.

func (*Builder) WithStart

func (b *Builder) WithStart(startFn func(context.Context, *ygnmi.Client) error) *Builder

WithStart appends a new start func to the reconciler.

func (*Builder) WithStop

func (b *Builder) WithStop(stopFn func(context.Context) error) *Builder

WithStop appends a new stop func to the reconciler.

func (*Builder) WithValidator

func (b *Builder) WithValidator(paths []ygnmi.PathStruct, validator func(*oc.Root) error) *Builder

WithValidator appends a validator and validations paths to the reconciler. The Validate func is only called if the SetRequest contains paths which match the paths.

type BuiltReconciler

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

BuiltReconciler is an implementation of the reconciler interface returned by builders.

func (*BuiltReconciler) ID

func (bt *BuiltReconciler) ID() string

func (*BuiltReconciler) Start

func (bt *BuiltReconciler) Start(ctx context.Context, client gpb.GNMIClient, target string) error

func (*BuiltReconciler) Stop

func (bt *BuiltReconciler) Stop(ctx context.Context) error

func (*BuiltReconciler) Validate

func (bt *BuiltReconciler) Validate(intendedConfig *oc.Root) error

func (*BuiltReconciler) ValidationPaths

func (bt *BuiltReconciler) ValidationPaths() []ygnmi.PathStruct

type Reconciler

type Reconciler interface {
	// ID the id for the reconciler.
	ID() string
	// Start start the reconciliation loop.
	// The client and target are connected to the local gNMI cache.
	// An error returned during Start will cause lemming to exit, so Start should return non-retriable errors.
	Start(ctx context.Context, client gpb.GNMIClient, target string) error
	// Stop stops the reconciliation loop.
	Stop(context.Context) error
	// Validate is called after a SetRequest is checked for schema compliance, but before data is written to the cache.
	// Reconcilers can validate the intended config for semantic correctness (reject config that can never be reconciled).
	// The Validate func is only called if the SetRequest contains paths which match the ValidationPaths.
	Validate(intendedConfig *oc.Root) error
	// ValidationPaths returns the set of path prefixes that the reconciler can validate.
	ValidationPaths() []ygnmi.PathStruct
}

Reconciler is a common interface for gNMI reconciler. Reconcilers are responsible for watching config and state and performing any necessary reconciliation.

type TypedBuilder

type TypedBuilder[T any] struct {
	Builder
}

TypedBuilder is similar to builder except with a type parameter for use with ygnmi Queries.

func NewTypedBuilder

func NewTypedBuilder[T any](id string) *TypedBuilder[T]

NewTypedBuilder creates a new reconciler builder.

func (*TypedBuilder[T]) WithWatch

func (tb *TypedBuilder[T]) WithWatch(query ygnmi.SingletonQuery[T], predicate func(context.Context, *ygnmi.Client, *ygnmi.Value[T]) error) *TypedBuilder[T]

WithWatch adds starting a watch to the reconciler's start funcs.

Jump to

Keyboard shortcuts

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