registry

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package registry is a freeze-after-boot name registry: Register during initialization, Freeze exactly once when wiring is complete, Lookup forever after. Post-freeze registration panics — mis-ordered boot wiring is a programming error, not a runtime condition — and freezing makes the read path safe for concurrent lock-free use.

Authored in G++ and distributed as generated Go — consumers never need the gpp toolchain.

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 maps names to values of T. The zero value is usable.

func New

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

New constructs an empty, unfrozen Registry.

func (*Registry[T]) Freeze

func (r *Registry[T]) Freeze()

Freeze seals the registry. Idempotent. After Freeze, Lookup reads the map without locking (no writer can exist).

func (*Registry[T]) Frozen

func (r *Registry[T]) Frozen() bool

Frozen reports whether Freeze has been called.

func (*Registry[T]) Lookup

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

Lookup returns the value registered under name; ok=false when absent. Lock-free once frozen; before Freeze it takes the mutex (boot-time reads are rare and must not race Register).

func (*Registry[T]) Names

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

Names returns the registered names in map order (callers sort if they need determinism).

func (*Registry[T]) Register

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

Register adds name → v. It panics if the registry is frozen or the name is already registered — both are boot-wiring bugs.

Jump to

Keyboard shortcuts

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