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)
- func RegisterSingleton[T any](ctx context.Context, factory func() T)
- 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
- 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") )
Functions ¶
func ContextWithDependencyProvider ¶ added in v0.9.0
func ContextWithDependencyProvider(ctx context.Context, dp *DependencyProvider) context.Context
func RegisterLazySingleton ¶
func RegisterSingleton ¶
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)
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.