injectinvoker

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrProviderNotFound = errors.New("no provider found that satisfies interface")

ErrProviderNotFound indicates that a provider was not found for the interface

View Source
var ErrUnsupportedType = errors.New("unsupported type")

ErrUnsupportedType indicates that the type of arg/field is not a struct or an interface

Functions

This section is empty.

Types

type Builder added in v0.1.4

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

Builder builds a slice of resources

func NewBuilder added in v0.1.4

func NewBuilder() *Builder

NewBuilder returns a new resource builder

func (*Builder) Add added in v0.1.4

func (b *Builder) Add(creator interface{}) *Builder

Add adds a new creator function. The function has zero or more args that define dependencies and a single return value. Note: The args must all be interfaces.

func (*Builder) Build added in v0.1.4

func (b *Builder) Build(providers ...interface{}) ([]interface{}, error)

Build returns a slice of resources using the given set of providers

type Invoker

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

Invoker is a dependency injecting function invoker that calls a given function, providing it with all required args.

func New

func New(providers ...interface{}) *Invoker

New returns a dependency injecting function invoker with the given set of providers.

func (*Invoker) AddProvider

func (inv *Invoker) AddProvider(provider interface{})

AddProvider adds a provider to the set of providers

func (*Invoker) Invoke

func (inv *Invoker) Invoke(fctn interface{}) ([]reflect.Value, error)

Invoke calls the given function, providing it with the required providers. Each of the interface arguments specified in the given function is injected with a provider that implements that interface. An error is returned if no suitable provider is found for any of the supplied arguments. Note: All of the arguments in the provided function must be interfaces.

Jump to

Keyboard shortcuts

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