registry

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package registry provides a generic, concurrency-safe name→factory registry. Each component kind (datapath, scheduler, generator, payload) keeps its own registry so new backends and protocols register themselves and drop in without a central switch. See DESIGN.md §5.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory[T any, O any] func(O) (T, error)

Factory builds a T from its options O.

type Registry

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

Registry maps names to factories for one component kind. T is the produced interface; O is that kind's options struct.

func New

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

New returns an empty Registry.

func (*Registry[T, O]) Build

func (r *Registry[T, O]) Build(name string, opts O) (T, error)

Build constructs the named component from opts, or returns an error naming the registered alternatives.

func (*Registry[T, O]) Names

func (r *Registry[T, O]) Names() []string

Names returns the registered names, sorted.

func (*Registry[T, O]) Register

func (r *Registry[T, O]) Register(name string, fn Factory[T, O])

Register adds a factory under name. It panics on a nil factory or a duplicate name, since registration happens at init time and both are programming errors.

Jump to

Keyboard shortcuts

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