Documentation
¶
Overview ¶
Package registry provides a thread-safe registry for storing and retrieving values of types via a string key. It ensures that each type is registered only once and provides error handling for duplicate registrations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
Register stores a type in the registry. It returns an error if the type is already registered, or if the type does not implement the Named interface and cannot be registered.
To register, a value of a type is provided. Implementing the Newable interface allows the registry to create and initialize a new value of the type for you based on the provided args, otherwise any initialization must be done manually.
Types ¶
type ErrTypeAlreadyRegistered ¶
type ErrTypeAlreadyRegistered struct{ Name string }
ErrObjectAlreadyRegistered is an error that is returned when a type is registered more than once.
func (ErrTypeAlreadyRegistered) Error ¶
func (e ErrTypeAlreadyRegistered) Error() string
Error returns the error message.
func (ErrTypeAlreadyRegistered) Is ¶
func (e ErrTypeAlreadyRegistered) Is(err error) bool
Is returns true if the error is of type ErrTypeAlreadyRegistered.
type ErrTypeNotRegistered ¶
type ErrTypeNotRegistered struct{ Name string }
ErrTypeDoesNotExist is an error that is returned when a type is not found in the registry.
func (ErrTypeNotRegistered) Error ¶
func (e ErrTypeNotRegistered) Error() string
Error returns the error message.
func (ErrTypeNotRegistered) Is ¶
func (e ErrTypeNotRegistered) Is(err error) bool
Is returns true if the error is of type ErrTypeNotRegistered.
type Named ¶
type Named interface {
Name() string
}
Named is an interface that provides a method to return the name of a type.