component

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrComponentNotRegistered = eris.New("component not registered")

Functions

func NewComponentMetadata

func NewComponentMetadata[T types.Component](opts ...Option[T]) (
	types.ComponentMetadata, error,
)

NewComponentMetadata creates a new component type. The function is used to create a new component of the type.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(schemaStorage SchemaStorage) *Manager

NewManager creates a new component manager.

func (*Manager) GetComponentByName

func (m *Manager) GetComponentByName(name string) (types.ComponentMetadata, error)

GetComponentByName returns the component metadata for the given component name.

func (*Manager) GetComponents

func (m *Manager) GetComponents() []types.ComponentMetadata

GetComponents returns a list of all registered components. Note: The order of the components in the list is not deterministic.

func (*Manager) RegisterComponent

func (m *Manager) RegisterComponent(compMetadata types.ComponentMetadata) error

RegisterComponent registers component with the component manager. There can only be one component with a given name, which is declared by the user by implementing the Name() method. If there is a duplicate component name, an error will be returned and the component will not be registered.

type Option

type Option[T types.Component] func(c *componentMetadata[T])

Option is a type that can be passed to NewComponentMetadata to augment the creation of the component type.

func WithDefault

func WithDefault[T types.Component](defaultVal T) Option[T]

WithDefault updated the created componentMetadata with a default value.

type SchemaStorage

type SchemaStorage interface {
	GetSchema(componentName string) ([]byte, error)
	SetSchema(componentName string, schemaData []byte) error
}

Jump to

Keyboard shortcuts

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