Documentation
¶
Index ¶
- Variables
- func ContextWithDependencyProvider(ctx context.Context, dp *DependencyProvider) context.Context
- func Fill(ctx context.Context, v any) error
- func IsFillable(v any) bool
- func PrepareFunc[T any](dp *DependencyProvider, fn any) T
- func PrepareFuncCtx[T any](fn any) T
- func Register[T any](ctx context.Context, factory func(ctx context.Context, tag string) (T, error))
- func RegisterFactory(ctx context.Context, factory Factory)
- func RegisterLazySingleton[T any](ctx context.Context, factory func() (T, error))
- func RegisterLazySingletonWith[T, W any](ctx context.Context, factory func(with W) (T, error))
- func RegisterSingleton[T any](ctx context.Context, factory func() T)
- func RegisterValue(ctx context.Context, t reflect.Type, ...)
- func RegisterWith[T, W any](ctx context.Context, ...)
- func Resolve[T any](ctx context.Context) (T, error)
- func TestDependencyProviderContext() context.Context
- type DIValidator
- type Dependant
- type DependencyProvider
- func (dp *DependencyProvider) Fill(ctx context.Context, v any) error
- func (d *DependencyProvider) Register(factory Factory)
- func (dp *DependencyProvider) Singletons() []Singleton
- func (dp *DependencyProvider) Validate(ctx context.Context) error
- func (dp *DependencyProvider) Validator(rootType reflect.Type) *DIValidator
- type Factory
- type FactoryFunc
- type FactoryFuncWith
- type LazySingletonFactory
- type LazySingletonWithFactory
- func (f *LazySingletonWithFactory[T, W]) Build(ctx context.Context, dp *DependencyProvider, tag string) (any, error)
- func (f *LazySingletonWithFactory[T, W]) DependsOn() []reflect.Type
- func (f *LazySingletonWithFactory[T, W]) Peek() (any, error, bool)
- func (f *LazySingletonWithFactory[T, W]) Type() reflect.Type
- type Singleton
- type SingletonFactory
- type ValueFactory
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotRegistered = errors.New("dependency not registered") ErrFillParameters = errors.New("invalid fill parameters") ErrDependencyProviderNotInContext = errors.New("DependencyProvider not in context") )
View Source
var ( ErrDependancyCycle = errors.New("dependancy cycle") ErrMissingDependancy = errors.New("missing dependancy") )
Functions ¶
func ContextWithDependencyProvider ¶
func ContextWithDependencyProvider(ctx context.Context, dp *DependencyProvider) context.Context
func IsFillable ¶
func PrepareFunc ¶
func PrepareFunc[T any](dp *DependencyProvider, fn any) T
func PrepareFuncCtx ¶
func RegisterFactory ¶
func RegisterLazySingleton ¶
func RegisterSingleton ¶
func RegisterValue ¶
func RegisterWith ¶
Types ¶
type DIValidator ¶
type DIValidator struct {
// contains filtered or unexported fields
}
type DependencyProvider ¶
type DependencyProvider struct {
// contains filtered or unexported fields
}
func GetDependencyProvider ¶
func GetDependencyProvider(ctx context.Context) *DependencyProvider
func NewDependencyProvider ¶
func NewDependencyProvider() *DependencyProvider
func (*DependencyProvider) Fill ¶
func (dp *DependencyProvider) Fill(ctx context.Context, v any) error
func (*DependencyProvider) Register ¶
func (d *DependencyProvider) Register(factory Factory)
func (*DependencyProvider) Singletons ¶
func (dp *DependencyProvider) Singletons() []Singleton
func (*DependencyProvider) Validate ¶
func (dp *DependencyProvider) Validate(ctx context.Context) error
func (*DependencyProvider) Validator ¶
func (dp *DependencyProvider) Validator(rootType reflect.Type) *DIValidator
type FactoryFunc ¶
func NewFactoryFunc ¶
func (FactoryFunc[T]) Build ¶
func (f FactoryFunc[T]) Build(ctx context.Context, dp *DependencyProvider, tag string) (any, error)
func (FactoryFunc[T]) Type ¶
func (f FactoryFunc[T]) Type() reflect.Type
type FactoryFuncWith ¶
func NewFactoryFuncWith ¶
func (FactoryFuncWith[T, W]) Build ¶
func (f FactoryFuncWith[T, W]) Build(ctx context.Context, dp *DependencyProvider, tag string) (any, error)
func (FactoryFuncWith[T, W]) DependsOn ¶
func (f FactoryFuncWith[T, W]) DependsOn() []reflect.Type
func (FactoryFuncWith[T, W]) Type ¶
func (f FactoryFuncWith[T, W]) Type() reflect.Type
type LazySingletonFactory ¶
type LazySingletonFactory[T any] struct { // contains filtered or unexported fields }
func NewLazySingletonFactory ¶
func NewLazySingletonFactory[T any](factory func() (T, error)) *LazySingletonFactory[T]
func (*LazySingletonFactory[T]) Build ¶
func (f *LazySingletonFactory[T]) Build(ctx context.Context, dp *DependencyProvider, tag string) (any, error)
func (*LazySingletonFactory[T]) Type ¶
func (f *LazySingletonFactory[T]) Type() reflect.Type
type LazySingletonWithFactory ¶
type LazySingletonWithFactory[T, W any] struct { // contains filtered or unexported fields }
func NewLazySingletonWithFactory ¶
func NewLazySingletonWithFactory[T, W any](factory func(with W) (T, error)) *LazySingletonWithFactory[T, W]
func (*LazySingletonWithFactory[T, W]) Build ¶
func (f *LazySingletonWithFactory[T, W]) Build(ctx context.Context, dp *DependencyProvider, tag string) (any, error)
func (*LazySingletonWithFactory[T, W]) DependsOn ¶
func (f *LazySingletonWithFactory[T, W]) DependsOn() []reflect.Type
func (*LazySingletonWithFactory[T, W]) Peek ¶
func (f *LazySingletonWithFactory[T, W]) Peek() (any, error, bool)
func (*LazySingletonWithFactory[T, W]) Type ¶
func (f *LazySingletonWithFactory[T, W]) Type() reflect.Type
type Singleton ¶
func Singletons ¶
type SingletonFactory ¶
type SingletonFactory[T any] struct { // contains filtered or unexported fields }
func NewSingletonFactory ¶
func NewSingletonFactory[T any](value T) *SingletonFactory[T]
func (*SingletonFactory[T]) Build ¶
func (f *SingletonFactory[T]) Build(ctx context.Context, dp *DependencyProvider, tag string) (any, error)
func (*SingletonFactory[T]) Type ¶
func (f *SingletonFactory[T]) Type() reflect.Type
type ValueFactory ¶
type ValueFactory struct {
// contains filtered or unexported fields
}
func NewValueFactory ¶
func (*ValueFactory) Build ¶
func (f *ValueFactory) Build(ctx context.Context, dp *DependencyProvider, tag string) (any, error)
func (*ValueFactory) Type ¶
func (f *ValueFactory) Type() reflect.Type
Click to show internal directories.
Click to hide internal directories.