inverse

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: GPL-3.0 Imports: 6 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInverseNilContext      = errors.New("container received nil context")
	ErrInverseResolveLoop     = errors.New("container dependency loop")
	ErrInverseResolverMissing = errors.New("container does not contain qualifier")
	ErrInverseResolveError    = errors.New("container failed to resolve qualifier")
	ErrInverseCastError       = errors.New("container value cast error")
)
View Source
var Global = NewContainer()

Functions

func GenericAdd added in v0.0.29

func GenericAdd[T any](c Container, qualifier string, injector Injector[T])

func GenericAddVal added in v0.0.29

func GenericAddVal[T any](c Container, qualifier string, instance T)

func GenericGet added in v0.0.29

func GenericGet[T any](c Container, ctx context.Context, qualifier string) (T, error)

func GenericGetAll added in v0.0.29

func GenericGetAll[T any](c Container, ctx context.Context, qualifier string) ([]T, error)

func GenericGetLast deprecated added in v0.0.29

func GenericGetLast[T any](c Container, ctx context.Context, qualifier string) (T, error)

Deprecated: use GenericGet instead to keep naming scheme consistent

func GetAll

func GetAll[T any](ctx context.Context, qualifier string) ([]T, error)

func GetLast

func GetLast[T any](ctx context.Context, qualifier string) (T, error)

func Qualifier

func Qualifier(name string) qualifier

func Register

func Register[T any](qualifier string, injector Injector[T])

func RegisterInstance added in v0.0.15

func RegisterInstance[T any](qualifier string, instance T)

func RegisterInstances added in v0.0.15

func RegisterInstances[T any](qualifier string, instances []T)

func Release

func Release()

func Reset

func Reset()

Types

type Container added in v0.0.29

type Container interface {
	Reset()
	Clear()
	Invalid(error)
	Valid() bool
	Error() error
	Add(q string, r Resolver)
	AddVal(q string, v any)
	Get(ctx context.Context, q string) (any, error)
	GetAll(ctx context.Context, q string) ([]any, error)
}

func NewContainer added in v0.0.29

func NewContainer() Container

type Injector

type Injector[T any] func(context.Context, Container) (T, error)

type Resolver added in v0.0.29

type Resolver func(context.Context, Container) (any, error)

Jump to

Keyboard shortcuts

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