clientreg

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package clientreg is the client registry every Worker Type shares: a name → client map that a worker resolves a model's worker reference through, plus the part that is not a map — *why* a worker an operator did configure is missing from it.

A worker that cannot be built (an endpoint naming no host, a credential bundle that will not parse, a provider nobody implements) is deliberately left out of the registry so its tasks park instead of running wrongly (ADR-0093). The reason used to be discarded at the point of skipping, and the parked token then reported "no worker registered as X" — which reads as *you never configured it* and sends an operator looking for a worker that is sitting right there, disabled or broken. So the registry carries the skipped ones too, with their reason, and the incident can say what is actually wrong (ADR-0158).

A Registry is read-only once populated and safe for concurrent use by workers; the server serializes Replace with the workers that read it on its run-loop goroutine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

type Registry[T any] struct {
	// contains filtered or unexported fields
}

Registry resolves a worker name to the client of its kind, and remembers the configured workers of that kind it could not build.

func New

func New[T any]() *Registry[T]

New creates an empty registry.

func (*Registry[T]) Client

func (r *Registry[T]) Client(name string) (T, bool)

Client returns the client bound to name, or the zero value and false if none is.

func (*Registry[T]) Problem

func (r *Registry[T]) Problem(name string) (string, bool)

Problem returns why a *configured* worker of this kind is not usable, and whether one was recorded at all. The distinction is the whole point: no problem and no client means nobody ever configured that name; a problem means somebody did and it is broken, disabled, or of another kind — which is a different thing for an operator to go and do.

func (*Registry[T]) Problems

func (r *Registry[T]) Problems() map[string]string

Problems returns every recorded reason, keyed by worker name. The caller must not mutate the result. It backs the operator view that lists a configured worker's health beside it.

func (*Registry[T]) Register

func (r *Registry[T]) Register(name string, c T)

Register binds a worker name to its client. Registering the same name again replaces the earlier binding (last write wins), so reconfiguration is simple, and clears any problem recorded under that name — it is usable now.

func (*Registry[T]) Replace

func (r *Registry[T]) Replace(clients map[string]T)

Replace swaps the whole set of registered workers at once, so a server can rebuild the registry from managed configuration after a change (ADR-0041). A nil map clears the registry. It records no problems; ReplaceWith is the form that carries them.

func (*Registry[T]) ReplaceWith

func (r *Registry[T]) ReplaceWith(clients map[string]T, problems map[string]string)

ReplaceWith swaps the registered workers *and* the reasons the configured ones that are missing could not be built, in one step — the two always come from the same rebuild pass, and letting them be set separately would allow a registry whose clients and explanations disagree.

func (*Registry[T]) Unresolved

func (r *Registry[T]) Unresolved(kind, name string) error

Unresolved is the error a worker returns when a model's worker reference does not resolve — the message an operator reads on the parked token. It distinguishes the two cases the registry can tell apart: a name nobody configured, and a name somebody configured that cannot be used and why. kind prefixes the message with the Worker Type, as every worker's errors do.

Jump to

Keyboard shortcuts

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