Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶ added in v0.2.13
type Builder[T any, C any] interface { // WithConfig sets the configuration for the builder WithConfig(config C) Builder[T, C] // WithOptions sets the dependencies for the builder WithOptions(opts ...options.Option) Builder[T, C] // Build creates a new instance of T Build() (T, error) }
Builder defines the interface for building instances with optional configuration and dependencies.
type ContextFunc ¶ added in v0.2.13
type ContextFunc[T any, C any] func(ctx context.Context, config C, opts ...options.Option) (T, error)
ContextFunc is a function that creates an instance of T with context support using the provided context, configuration and options.
type CtxFuncRegistry ¶ added in v0.2.13
type CtxFuncRegistry[T any, C any] struct { Registry[ContextFunc[T, C]] }
CtxFuncRegistry is a specialized registry for context-aware factory functions
func NewCtxFuncRegistry ¶ added in v0.2.13
func NewCtxFuncRegistry[T any, C any]() *CtxFuncRegistry[T, C]
NewCtxFuncRegistry creates a new CtxFuncRegistry
type ErrFactoryNotFound ¶ added in v0.2.13
type ErrFactoryNotFound struct {
Name string
}
ErrFactoryNotFound is returned when a requested factory is not found
func (ErrFactoryNotFound) Error ¶ added in v0.2.13
func (e ErrFactoryNotFound) Error() string
Error implements error interface
func (ErrFactoryNotFound) Is ¶ added in v0.2.13
func (e ErrFactoryNotFound) Is(target error) bool
Is implements the interface used by errors.Is
type Func ¶ added in v0.2.13
Func is a function that creates an instance of T using the provided configuration and options.
type FuncRegistry ¶ added in v0.2.13
FuncRegistry is a specialized registry for factory functions that create instances of type T using configuration of type C.
func NewFuncRegistry ¶ added in v0.2.13
func NewFuncRegistry[T any, C any]() *FuncRegistry[T, C]
NewFuncRegistry creates a new FuncRegistry
type Registry ¶
type Registry[F any] interface { // Get retrieves a factory by name Get(name string) (F, bool) // Register adds or updates a factory with the given name Register(name string, factory F) // RegisteredFactories returns all registered factories RegisteredFactories() map[string]F // Reset removes all registered factories Reset() }
Registry defines the interface for managing factory functions. It allows for registering and retrieving factory functions by name.
type RegistryBuilder ¶ added in v0.2.13
RegistryBuilder is a specialized registry for builders that create instances of type T using configuration of type C.
func NewRegistryBuilder ¶ added in v0.2.13
func NewRegistryBuilder[T any, C any]() *RegistryBuilder[T, C]
NewRegistryBuilder creates a new RegistryBuilder
func (*RegistryBuilder[T, C]) Create ¶ added in v0.2.13
func (r *RegistryBuilder[T, C]) Create(name string, config C, opts ...options.Option) (T, error)
Create creates a new instance using the builder registered with the given name
func (*RegistryBuilder[T, C]) CreateBuilder ¶ added in v0.2.13
func (r *RegistryBuilder[T, C]) CreateBuilder(name string) (Builder[T, C], error)
CreateBuilder creates a new builder using the factory registered with the given name