registry

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package registry holds the type-erased entries built by spec.Define and hands them to the transport frontends. Registration validates name uniqueness eagerly so collisions surface at startup, not at first call.

The package also owns the process-wide default registry (Default): the one-main-entry program registers into it via spec.Command[T].RegisterDefault() and lets xyz.Main() dispatch it, with no registry construction or import in user code. Programs that need several registries (or test isolation) keep using New with the explicit Register / Run variants.

Index

Constants

This section is empty.

Variables

View Source
var Default = New()

Default is the process-wide registry behind spec.RegisterDefault and xyz.Main. Programs rarely need to touch it directly.

Functions

func Add

func Add(e *spec.Entry) error

Add registers an entry into Default. Name collisions are an error.

Types

type Registry

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

Registry is the central command table shared by every frontend.

func New

func New() *Registry

New returns an empty Registry.

func (*Registry) Add

func (r *Registry) Add(e *spec.Entry) error

Add registers an entry. Name collisions are an error.

func (*Registry) All

func (r *Registry) All() []*spec.Entry

All returns all entries sorted by name.

func (*Registry) Get

func (r *Registry) Get(name string) (*spec.Entry, bool)

Get returns the entry registered under name.

func (*Registry) Names

func (r *Registry) Names() []string

Names returns all registered names, sorted.

Jump to

Keyboard shortcuts

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