Documentation ¶
Index ¶
- Variables
- func ContextWithDependencyProvider(ctx context.Context, dp *DependencyProvider) context.Context
- func Fill(ctx context.Context, v any, opts ...FillOption) error
- func Register[T any](ctx context.Context, factory DependencyFactory[T])
- 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 ResolveFill[T any](ctx context.Context) (T, error)
- func TestDependencyProviderContext() context.Context
- func Validate(ctx context.Context, v any, opts ...FillOption) error
- type DependencyFactory
- type DependencyProvider
- type FillOption
- type FillOptions
- type Fillable
- type IsFillabler
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidDependencyFactory = errors.New("dependency factories must match the type di.DependencyFactory") ErrNotRegistered = errors.New("dependency not registered") ErrFillParameters = errors.New("invalid fill parameters") ErrDependencyProviderNotInContext = errors.New("DependencyProvider not in context") )
View Source
var ErrNotFillable = errors.New("struct is not fillable")
Functions ¶
func ContextWithDependencyProvider ¶ added in v0.9.0
func ContextWithDependencyProvider(ctx context.Context, dp *DependencyProvider) context.Context
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 DependencyFactory ¶
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, opts ...FillOption) error
func (*DependencyProvider) Register ¶
func (d *DependencyProvider) Register(factory any)
factory should be of type DependencyFactory[T any] func(ctx context.Context, tag string) (T, error)
func (*DependencyProvider) RegisterValue ¶ added in v0.14.0
func (*DependencyProvider) Validate ¶ added in v0.11.0
func (dp *DependencyProvider) Validate(ctx context.Context, v any, opts ...FillOption) error
type FillOption ¶
type FillOption func(*FillOptions) *FillOptions
func AutoResolve ¶
func AutoResolve[T any]() FillOption
type FillOptions ¶
type FillOptions struct {
// contains filtered or unexported fields
}
type IsFillabler ¶
type IsFillabler interface {
IsFillable() bool
}
Click to show internal directories.
Click to hide internal directories.