Documentation ¶
Overview ¶
Package reconciler contains a common interface for gNMI reconciler.
Index ¶
- type Builder
- func (b *Builder) Build() *BuiltReconciler
- func (b *Builder) WithStart(startFn func(context.Context, *ygnmi.Client) error) *Builder
- func (b *Builder) WithStop(stopFn func(context.Context) error) *Builder
- func (b *Builder) WithValidator(paths []ygnmi.PathStruct, validator func(*oc.Root) error) *Builder
- type BuiltReconciler
- func (bt *BuiltReconciler) ID() string
- func (bt *BuiltReconciler) Start(ctx context.Context, client gpb.GNMIClient, target string) error
- func (bt *BuiltReconciler) Stop(ctx context.Context) error
- func (bt *BuiltReconciler) Validate(intendedConfig *oc.Root) error
- func (bt *BuiltReconciler) ValidationPaths() []ygnmi.PathStruct
- type Reconciler
- type TypedBuilder
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 (*Builder) Build ¶
func (b *Builder) Build() *BuiltReconciler
Build returns the reconciler as configuration and resets the builder.
func (*Builder) WithValidator ¶
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) 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 ¶
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.