controller

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package controller is the one general reconcile engine (ADR-0015): a store-watch informer feeds a rate-limited, deduplicating workqueue that worker goroutines drain by calling each kind's registered Reconciler — with exponential-backoff retry, RequeueAfter, status write-back (the reconciler's), and clean shutdown. Every control-plane feature contributes only a Reconciler; the engine owns the watch/queue/retry/worker machinery. k8s-free (the workqueue is hand-written).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

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

Controller is the reconcile engine.

func New

func New(d Deps) (*Controller, error)

New builds the engine. Store is required.

func (*Controller) Register

func (c *Controller) Register(gvk v1.GroupVersionKind, r Reconciler)

Register binds a Reconciler to a gvk. Call before Run.

func (*Controller) Run

func (c *Controller) Run(ctx context.Context) error

Run opens a store Watch per registered gvk (the informer), starts the workers, blocks until ctx is cancelled, then drains the watches and workers — no leak.

type Deps

type Deps struct {
	Store   store.Store
	Logger  *slog.Logger
	Workers int // number of worker goroutines; <1 defaults to 1
}

Deps configures the engine (internal component, ADR-0002 §1).

type Reconciler

type Reconciler interface {
	Reconcile(ctx context.Context, req Request) (Result, error)
}

Reconciler is the per-kind logic a feature contributes. It must be idempotent (the queue is at-least-once). A delete surfaces as fault.NotFound from the store.

type Request

type Request struct {
	GVK       v1.GroupVersionKind
	Namespace v1.NamespaceName
	Name      v1.ObjectName
}

Request identifies the object to reconcile; it is also the workqueue key (comparable).

type Result

type Result struct {
	Requeue      bool
	RequeueAfter time.Duration
}

Result tells the engine whether/when to re-reconcile.

Jump to

Keyboard shortcuts

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