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 ¶ added in v0.9.0
func ContextWithDependencyProvider(ctx context.Context, dp *DependencyProvider) context.Context
func IsFillable ¶ added in v0.16.1
func PrepareFunc ¶ added in v0.16.0
func PrepareFunc[T any](dp *DependencyProvider, fn any) T
func PrepareFuncCtx ¶ added in v0.16.0
func RegisterFactory ¶ added in v0.15.0
func RegisterLazySingleton ¶
func RegisterLazySingletonWith ¶ added in v0.10.2
func RegisterSingleton ¶
func RegisterValue ¶ added in v0.14.0
func RegisterWith ¶
func TestDependencyProviderContext ¶ added in v0.9.0
Types ¶
type DIValidator ¶ added in v0.15.0
type DIValidator struct {
// contains filtered or unexported fields
}
type DependencyProvider ¶
type DependencyProvider struct {
// contains filtered or unexported fields
}
func GetDependencyProvider ¶ added in v0.9.0
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 ¶ added in v0.15.0
func (dp *DependencyProvider) Singletons() []Singleton
func (*DependencyProvider) Validate ¶ added in v0.11.0
func (dp *DependencyProvider) Validate(ctx context.Context) error
func (*DependencyProvider) Validator ¶ added in v0.15.0
func (dp *DependencyProvider) Validator(rootType reflect.Type) *DIValidator
type FactoryFunc ¶ added in v0.15.0
func NewFactoryFunc ¶ added in v0.15.0
func (FactoryFunc[T]) Build ¶ added in v0.15.0
func (f FactoryFunc[T]) Build(ctx context.Context, dp *DependencyProvider, tag string) (any, error)
func (FactoryFunc[T]) Type ¶ added in v0.15.0
func (f FactoryFunc[T]) Type() reflect.Type
type FactoryFuncWith ¶ added in v0.16.0
func NewFactoryFuncWith ¶ added in v0.16.0
func (FactoryFuncWith[T, W]) Build ¶ added in v0.16.0
func (f FactoryFuncWith[T, W]) Build(ctx context.Context, dp *DependencyProvider, tag string) (any, error)
func (FactoryFuncWith[T, W]) DependsOn ¶ added in v0.16.0
func (f FactoryFuncWith[T, W]) DependsOn() []reflect.Type
func (FactoryFuncWith[T, W]) Type ¶ added in v0.16.0
func (f FactoryFuncWith[T, W]) Type() reflect.Type
type LazySingletonFactory ¶ added in v0.15.0
type LazySingletonFactory[T any] struct { // contains filtered or unexported fields }
func NewLazySingletonFactory ¶ added in v0.15.0
func NewLazySingletonFactory[T any](factory func() (T, error)) *LazySingletonFactory[T]
func (*LazySingletonFactory[T]) Build ¶ added in v0.15.0
func (f *LazySingletonFactory[T]) Build(ctx context.Context, dp *DependencyProvider, tag string) (any, error)
func (*LazySingletonFactory[T]) Peek ¶ added in v0.15.0
func (f *LazySingletonFactory[T]) Peek() (any, error, bool)
func (*LazySingletonFactory[T]) Type ¶ added in v0.15.0
func (f *LazySingletonFactory[T]) Type() reflect.Type
type LazySingletonWithFactory ¶ added in v0.16.0
type LazySingletonWithFactory[T, W any] struct { // contains filtered or unexported fields }
func NewLazySingletonWithFactory ¶ added in v0.16.0
func NewLazySingletonWithFactory[T, W any](factory func(with W) (T, error)) *LazySingletonWithFactory[T, W]
func (*LazySingletonWithFactory[T, W]) Build ¶ added in v0.16.0
func (f *LazySingletonWithFactory[T, W]) Build(ctx context.Context, dp *DependencyProvider, tag string) (any, error)
func (*LazySingletonWithFactory[T, W]) DependsOn ¶ added in v0.16.0
func (f *LazySingletonWithFactory[T, W]) DependsOn() []reflect.Type
func (*LazySingletonWithFactory[T, W]) Peek ¶ added in v0.16.0
func (f *LazySingletonWithFactory[T, W]) Peek() (any, error, bool)
func (*LazySingletonWithFactory[T, W]) Type ¶ added in v0.16.0
func (f *LazySingletonWithFactory[T, W]) Type() reflect.Type
type Singleton ¶ added in v0.15.0
func Singletons ¶ added in v0.15.0
type SingletonFactory ¶ added in v0.15.0
type SingletonFactory[T any] struct { // contains filtered or unexported fields }
func NewSingletonFactory ¶ added in v0.15.0
func NewSingletonFactory[T any](value T) *SingletonFactory[T]
func (*SingletonFactory[T]) Build ¶ added in v0.15.0
func (f *SingletonFactory[T]) Build(ctx context.Context, dp *DependencyProvider, tag string) (any, error)
func (*SingletonFactory[T]) Peek ¶ added in v0.15.0
func (f *SingletonFactory[T]) Peek() (any, error, bool)
func (*SingletonFactory[T]) Type ¶ added in v0.15.0
func (f *SingletonFactory[T]) Type() reflect.Type
type ValueFactory ¶ added in v0.15.0
type ValueFactory struct {
// contains filtered or unexported fields
}
func NewValueFactory ¶ added in v0.15.0
func (*ValueFactory) Build ¶ added in v0.15.0
func (f *ValueFactory) Build(ctx context.Context, dp *DependencyProvider, tag string) (any, error)
func (*ValueFactory) Type ¶ added in v0.15.0
func (f *ValueFactory) Type() reflect.Type
Source Files ¶
Click to show internal directories.
Click to hide internal directories.