familyregistry

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package familyregistry provides a generic, thread-safe registry mapping a string key (typically a chain-selectors family) to a per-family implementation.

Changeset packages use it to register family-specific operations sequences and optional verify hooks without duplicating registry boilerplate.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registration

type Registration[S any, C any] struct {
	// Family is the chain-selectors family string (e.g. chainselectors.FamilyEVM).
	Family string
	// Sequence executes the per-chain operations sequence.
	Sequence *S
	// Verify performs family-specific validation across all chains in the input.
	// It is called during VerifyPreconditions. Optional — nil means no extra checks.
	Verify func(env cldf.Environment, chains []C) error
}

Registration describes one family's implementation, where S is the operations sequence type and C is the per-chain input type.

type Registry

type Registry[S any, C any] struct {
	// contains filtered or unexported fields
}

Registry is a thread-safe map of family to Registration.

func New

func New[S any, C any](label string) *Registry[S, C]

New returns an empty registry. label prefixes panic and error messages.

func (*Registry[S, C]) Get

func (r *Registry[S, C]) Get(family string) (Registration[S, C], error)

Get returns the Registration for a chain family, or an error listing the registered families when the family is not found.

func (*Registry[S, C]) Register

func (r *Registry[S, C]) Register(reg Registration[S, C])

Register adds a family implementation. It panics if the family string is empty, Sequence is nil, or the family is already registered — all of which indicate a programming error at startup.

func (*Registry[S, C]) RegisteredFamilies

func (r *Registry[S, C]) RegisteredFamilies() []string

RegisteredFamilies returns the sorted list of families with a registration.

func (*Registry[S, C]) SequenceForChainSelector

func (r *Registry[S, C]) SequenceForChainSelector(chainSelector uint64) (*S, error)

SequenceForChainSelector returns the registered sequence for a chain selector.

func (*Registry[S, C]) SequenceForFamily

func (r *Registry[S, C]) SequenceForFamily(family string) (*S, error)

SequenceForFamily returns the registered sequence for a chain family.

func (*Registry[S, C]) VerifyForFamily

func (r *Registry[S, C]) VerifyForFamily(family string, env cldf.Environment, chains []C) error

VerifyForFamily runs the registered family verify hook, if any. It returns nil when the family registers no hook, and wraps hook errors with the family.

Jump to

Keyboard shortcuts

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