connreconcile

package
v1.102.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package connreconcile owns the single copy of the "materialize a DB-managed connection onto the live toolkits" mechanics shared by the admin hot-reload path and the cross-replica reload bus.

Both callers previously carried their own copy of the same loop — find every registered toolkit of a kind that implements toolkit.ConnectionManager, then remove-then-add under a HasConnection guard — and the copies had drifted: the admin path touched only the first matching toolkit while the reload bus touched all of them. Centralizing the loop here keeps the two paths from diverging again. Callers retain their own observability and broadcast policy; the reconciler reports which toolkit operations failed and leaves logging, log level, and peer notification to the caller.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Failure

type Failure struct {
	Phase Phase
	Err   error
}

Failure is one toolkit operation that returned an error during a reconcile. The reconciler reports what failed; the caller owns logging policy (level, message, structured fields).

type Phase

type Phase int

Phase identifies which toolkit operation produced a Failure so callers can tailor the log message: a failed remove-before-re-add reads differently from a failed add.

const (
	// PhaseRemove marks a failure returned by RemoveConnection.
	PhaseRemove Phase = iota
	// PhaseAdd marks a failure returned by AddConnection.
	PhaseAdd
)

func (Phase) String

func (p Phase) String() string

String renders the phase for structured log output.

type Reconciler

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

Reconciler applies connection changes to every registered toolkit of a given kind that implements toolkit.ConnectionManager. It holds no mutable state of its own: the source is the authority on which toolkits currently exist, so a reconciler is cheap to construct per call.

func New

func New(source ToolkitSource) *Reconciler

New returns a Reconciler bound to the given toolkit source. A nil source is tolerated (every operation becomes a no-op), matching the platform and admin wiring where the toolkit registry may be absent.

func (*Reconciler) Remove

func (r *Reconciler) Remove(kind, name string) []Failure

Remove drops name from every matching toolkit that currently holds it. Toolkits that do not hold the connection are skipped, because removing an absent connection is not a state-corrupting error (several toolkits return a not-found error for it). Returns one Failure per toolkit whose RemoveConnection returned an error, in registration order.

func (*Reconciler) Upsert

func (r *Reconciler) Upsert(kind, name string, config map[string]any) []Failure

Upsert makes config the live config for name on every matching toolkit, removing an existing registration first so a changed config replaces the old one rather than layering on top of it. A toolkit whose remove fails is skipped (its add is not attempted, to avoid stacking on stale state) but the loop continues so other toolkits of the same kind are still updated. Returns one Failure per failed operation, in registration order.

type ToolkitSource

type ToolkitSource interface {
	All() []registry.Toolkit
}

ToolkitSource is the minimal view of the toolkit registry the reconciler needs. Both *registry.Registry and the admin handler's registry seam satisfy it via their All method.

Jump to

Keyboard shortcuts

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