di

package
v0.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2024 License: MIT Imports: 7 Imported by: 10

Documentation

Index

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")
)

Functions

func Register

func Register[T any](dp *DependencyProvider, factory DependencyFactory[T])

func RegisterLazySingleton

func RegisterLazySingleton[T any](dp *DependencyProvider, factory func() T)

func RegisterSingleton

func RegisterSingleton[T any](dp *DependencyProvider, factory func() T)

func RegisterWith

func RegisterWith[T, W any](dp *DependencyProvider, factory func(ctx context.Context, tag string, with W) (T, error))

func Resolve

func Resolve[T any](ctx context.Context, dp *DependencyProvider) (T, error)

Types

type DependencyFactory

type DependencyFactory[T any] func(ctx context.Context, tag string) (T, error)

type DependencyProvider

type DependencyProvider struct {
	// contains filtered or unexported fields
}

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)

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 Fillable

type Fillable struct{}

func (*Fillable) IsFillable

func (*Fillable) IsFillable() bool

type IsFillabler

type IsFillabler interface {
	IsFillable() bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL