component

package
v0.0.0-...-cfe5bfc Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

type Loader[T, C any] func(ctx context.Context, config C) (T, error)

Loader returns a component of type `T` for the configuration `config` of type `C`.

type NamedLoader

type NamedLoader[T, C any] func() (string, Loader[T, C])

NamedLoader returns a name/loader pair for a component that is used to add to an instance of `Registry`.

func Named

func Named[T, C any](name string, loader Loader[T, C]) NamedLoader[T, C]

Named is a shorthand wrapper around creating a dynamically named component.

type Registry

type Registry[T, C any] map[string]Loader[T, C]

Registry is a simple map of name to `Loader` so that component loaders can be looked up by name.

func NewRegistry

func NewRegistry[T, C any](namedLoaders ...NamedLoader[T, C]) Registry[T, C]

NewRegistry returns a pre-populated `Registry` based on the provided `namedLoaders`.

func (Registry[T, C]) Register

func (r Registry[T, C]) Register(namedLoaders ...NamedLoader[T, C])

Register adds name/loader pairs to an existing `Registry` by calling each of the `namedLoaders`.

Jump to

Keyboard shortcuts

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