reconciler

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package reconciler implements the engine that converges the STUNner object tree to a desired StunnerConfig. The tree shape is fully described by the object catalog (internal/object); the engine walks it recursively, asks each object to Inspect its desired config (constructing missing objects on the fly), and applies the resulting operations in globally ordered phases: plan -> construct -> stop -> reconcile -> register -> delete -> start.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Catalog

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

Catalog stores the object kind specifications walked by the reconciler.

func NewCatalogFromKinds

func NewCatalogFromKinds(specs ...KindSpec) *Catalog

NewCatalogFromKinds builds a catalog from explicit kind specs.

func (*Catalog) Kind

func (c *Catalog) Kind(objType runtime.ObjectType) (KindSpec, bool)

Kind returns the type specification for an object type.

type KindSpec

type KindSpec struct {
	// Type is the object kind described by this spec.
	Type runtime.ObjectType

	// Children lists the child kinds living under instances of this kind.
	Children []runtime.ObjectType

	// New constructs an instance. The parent is the owning node (nil for the root).
	New func(parent runtime.Runnable, conf stnrv2.Config, rt *runtime.Runtime) (runtime.Runnable, error)

	// ExtractConfigs answers: "given this parent and this full desired config, which instances of
	// this kind should exist under the parent, and with what configs?" It is given the parent's
	// name rather than the parent object, so it can only read the desired config and never stale
	// parent object state (parentName is "" for the root's kind).
	ExtractConfigs func(parentName string, full *stnrv2.StunnerConfig) ([]stnrv2.Config, error)

	// Singleton marks kinds with exactly one instance per parent; SingletonName resolves the
	// instance name from the parent's name ("" for the root's kind).
	Singleton     bool
	SingletonName func(parentName string) string
}

KindSpec is the complete declarative description of one object kind: its constructor, its desired-config resolver, and its child kinds.

type Policy

type Policy struct {
	SuppressRollback bool
	DryRun           bool
}

Policy holds root-only reconciliation behavior knobs.

type Reconciler

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

Reconciler converges the object tree to a desired config, driven by the catalog.

func New

func New(catalog *Catalog, rt *runtime.Runtime, logger logging.LoggerFactory) *Reconciler

New creates a Reconciler over a catalog and a runtime.

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(req *stnrv2.StunnerConfig, p Policy) error

Reconcile runs one reconcile against the tree and applies root-only behavior (validation, snapshotting, rollback, dry-run).

func (*Reconciler) Shutdown

func (r *Reconciler) Shutdown() error

Shutdown closes every object in the tree with shutdown=true (children-first) and removes it from the registry.

Jump to

Keyboard shortcuts

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