injectors

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Creator

type Creator func(i *Injector, v interface{}) (interface{}, error)

type Injector

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

func NewInjector

func NewInjector() *Injector

func (*Injector) AddCreator

func (i *Injector) AddCreator(creator Creator, alias string) error

AddCreator adds a creator for a giving reflect type which will return a value from the function everytime it's called. This can return a new value or the same, the creator decides that.

func (*Injector) AddTypeValue

func (i *Injector) AddTypeValue(targetType interface{}, alias string) error

AddTypeValue works similar to Injector.AddValue and adds giving type which is used to generate a new type with the provided item supplied as the value of that type.

When you use a instance of that type, then the address of that instance is copied over and returned to you.

func (*Injector) AddValue

func (i *Injector) AddValue(v interface{}, name string) error

AddValue registers a giving value as is based on the name provided. We treat the value as is and no operation is performed, whenever the name is resolved from the injector the value of v is always returned.

func (*Injector) Resolve

func (i *Injector) Resolve(nameOrAlias string, args interface{}) (interface{}, error)

Resolve allows resolution of a type based on name or alias which is used to execute the appropriate creator to create giving type.

func (*Injector) ResolveType

func (i *Injector) ResolveType(targetType interface{}, args interface{}) (interface{}, error)

ResolveType attempts resolving into a type based on the actual reflect type information from the provided type. It returns the result of the generator.

Jump to

Keyboard shortcuts

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