registry

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package registry is the kind-to-instance table that NewSentinel writes and errors/wire reads, so a decoded leaf can become the registered instance again (spec 0003 D5). It is internal because only those two may write to it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KindOf

func KindOf(err error) (string, bool)

KindOf returns the kind err was registered under, with ok true only when err is that kind's one instance. The first two instances of an ambiguous kind get the kind with ok false, and a third or later, which is not recorded, gets "".

func Lookup

func Lookup(kind string) (error, bool)

Lookup returns the one instance registered under kind.

func Register

func Register(kind string, err error)

Register records err under kind. An empty kind is ignored. A kind under a reserved prefix, an uncomparable instance, and an instance already registered under another kind are refused and reported by Conflicts.

func RegisterBuiltin

func RegisterBuiltin(kind string, err error)

RegisterBuiltin records err under kind with no prefix check. Only errors/wire calls it, for the standard-library leaves under std.

func RegisterNew

func RegisterNew(kind string, err error)

RegisterNew records err under kind, as Register does, for an instance the caller has just created. It skips the identity scan, so registering N sentinels is linear rather than quadratic.

Types

type Conflict

type Conflict struct {
	Kind   string
	Reason Reason
}

Conflict is one kind a registration asked for that will not decode to its instance.

func Conflicts

func Conflicts() []Conflict

Conflicts lists every kind a registration asked for that will not decode to its instance, sorted by kind.

type Reason

type Reason int

Reason says why a kind will not decode to its registered instance.

const (
	// Ambiguous means two different instances were registered under the kind,
	// or the instance was already registered under another kind.
	Ambiguous Reason = iota + 1
	// Reserved means the kind is under a prefix only the core may use.
	Reserved
	// Uncomparable means the instance's type cannot be compared with ==, so a
	// leaf can never be recognised as it.
	Uncomparable
)

func (Reason) String

func (r Reason) String() string

Jump to

Keyboard shortcuts

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