di

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder interface {
	Provide(provider interface{}, options ...ProvideOption)
}

Builder is helper interface.

type Container

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

Container is a dependency injection container.

func New

func New() *Container

New create new container.

func (*Container) Cleanup

func (c *Container) Cleanup()

Cleanup runs destructors in order that was been created.

func (*Container) Compile

func (c *Container) Compile()

Compile compiles the container. It iterates over all nodes in graph and register their parameters.

func (*Container) Extract

func (c *Container) Extract(target interface{}, options ...ExtractOption) error

Extract builds instance of target type and fills target pointer.

func (*Container) Invoke

func (c *Container) Invoke(fn interface{}, options ...InvokeOption) error

Invoke calls provided function.

func (*Container) Provide

func (c *Container) Provide(constructor interface{}, options ...ProvideOption)

Provide adds constructor into container with parameters.

type ErrParameterProvideFailed

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

ErrParameterProvideFailed

func (ErrParameterProvideFailed) Error

type ErrParameterProviderNotFound

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

ErrParameterProviderNotFound

func (ErrParameterProviderNotFound) Error

type ExtractOption

type ExtractOption interface {
	// contains filtered or unexported methods
}

ExtractOption

type ExtractParams

type ExtractParams struct {
	Name string
}

ExtractParams

type Graph

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

Graph

func (*Graph) String

func (g *Graph) String() string

func (*Graph) WriteTo

func (g *Graph) WriteTo(writer io.Writer)

type Interactor

type Interactor interface {
	Extract(target interface{}, options ...ExtractOption) error
	Invoke(fn interface{}, options ...InvokeOption) error
}

Interactor is a helper interface.

type InvokeOption

type InvokeOption interface {
	// contains filtered or unexported methods
}

InvokeOption

type InvokeParams

type InvokeParams struct{}

InvokeParams is a invoke parameters.

type Parameter

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

Parameter

type ParameterBag

type ParameterBag map[string]interface{}

ParameterBag

func (ParameterBag) Exists

func (b ParameterBag) Exists(key string) bool

Exists

func (ParameterBag) Float64

func (b ParameterBag) Float64(key string) (float64, bool)

Float64

func (ParameterBag) Get

func (b ParameterBag) Get(key string) (interface{}, bool)

Get

func (ParameterBag) Int

func (b ParameterBag) Int(key string) (int, bool)

Int

func (ParameterBag) Int64

func (b ParameterBag) Int64(key string) (int64, bool)

Int64

func (ParameterBag) Require

func (b ParameterBag) Require(key string) interface{}

Require

func (ParameterBag) RequireFloat64

func (b ParameterBag) RequireFloat64(key string) float64

RequireFloat64

func (ParameterBag) RequireInt

func (b ParameterBag) RequireInt(key string) int

RequireInt

func (ParameterBag) RequireInt64

func (b ParameterBag) RequireInt64(key string) int64

RequireInt64

func (ParameterBag) RequireString

func (b ParameterBag) RequireString(key string) string

RequireString

func (ParameterBag) String

func (b ParameterBag) String(key string) (string, bool)

String

type ProvideOption

type ProvideOption interface {
	// contains filtered or unexported methods
}

ExtractOption

func As

func As(interfaces ...interface{}) ProvideOption

As

type ProvideParams

type ProvideParams struct {
	Name        string
	Interfaces  []interface{}
	Parameters  ParameterBag
	IsPrototype bool
}

ProvideParams is a `Provide()` method options. Name is a unique identifier of type instance. Provider is a constructor function. Interfaces is a interface that implements a provider result type.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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