registry

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package registry provides a generic, thread-safe provider registry for Diverge extension points. Each provider kind (router, deployer, database, notifier) instantiates its own Registry[T] to manage named provider factories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	// Client is the controller-runtime Kubernetes client.
	Client client.Client
	// Scheme is the runtime scheme with registered API types.
	Scheme *runtime.Scheme
	// Logger is a structured logger for the provider.
	Logger logr.Logger
}

Deps holds the universal dependencies passed to provider factories.

type Provider

type Provider[T any] struct {
	// Create constructs the provider from the given dependencies.
	Create func(deps Deps) (T, error)
	// Description is a one-line summary shown in --help output.
	Description string
}

Provider describes a named provider factory.

type Registry

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

Registry is a thread-safe, named-factory store for a single provider kind.

func New

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

New creates a new Registry for the given provider kind.

func (*Registry[T]) Create

func (r *Registry[T]) Create(name string, deps Deps) (T, error)

Create looks up a provider by name and invokes its factory. Returns a descriptive error listing available providers if not found.

func (*Registry[T]) Describe

func (r *Registry[T]) Describe() map[string]string

Describe returns a map of provider names to their descriptions.

func (*Registry[T]) List

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

List returns the sorted names of all registered providers.

func (*Registry[T]) Register

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

Register adds a named provider factory to the registry. It panics if the name is already registered or if the factory is nil. This is typically called from init() functions.

Jump to

Keyboard shortcuts

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