Documentation
¶
Overview ¶
Package registry provides a generic, domain-agnostic name→constructor registry. It lets a low-level package expose a lookup-by-name facility without depending on the high-level types being constructed: concrete constructors are bound at the composition root. The type parameter T is a generic constraint, not a dynamically-typed value, mirroring the existing llm.StreamReader[T any] precedent.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DuplicateNameError ¶
type DuplicateNameError struct{ Name string }
DuplicateNameError is returned by Registry.Register when a name is already bound to a constructor. It is a leaf error carrying the offending name; callers may errors.As to inspect it. Registration fails secure (the existing binding is never overwritten).
func (DuplicateNameError) Error ¶
func (e DuplicateNameError) Error() string
type Registry ¶
type Registry[T any] struct { // contains filtered or unexported fields }
Registry maps a name to a constructor that builds a value of type T. The zero Registry is not usable; construct one with New so the backing map is initialized.
func (*Registry[T]) Names ¶
Names returns the registered names sorted ascending. The result is a fresh slice; mutating it does not affect the registry.
func (*Registry[T]) Open ¶
Open constructs the value bound to name. If name was never registered it returns the zero T and a *UnknownNameError whose Known field lists the registered names in ascending order. If the constructor itself fails, Open returns the zero T and the constructor's error unchanged.
type UnknownNameError ¶
UnknownNameError is returned by Registry.Open when a name was never registered. Known lists the registered names in ascending order so callers can surface valid choices. It is a leaf error with context fields and is errors.As-able.
func (UnknownNameError) Error ¶
func (e UnknownNameError) Error() string