graph

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTypeNotProvided = errors.New("type not provided")
)

Functions

This section is empty.

Types

type Arguments

type Arguments interface {
	Arguments() (args []Key)
}

Arguments ...

type GroupNode

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

GroupNode is a group node.

func (*GroupNode) Add

func (n *GroupNode) Add(node *ProviderNode) (err error)

Add adds provider node to group.

func (*GroupNode) ArgumentNodes

func (n *GroupNode) ArgumentNodes() (args []Node)

ArgumentNodes return another nodes that included in this group. todo: Arguments() and ArgumentNodes() is too similar

func (*GroupNode) Arguments

func (n *GroupNode) Arguments() (args []Key)

Arguments returns another node keys that included in this group node.

func (*GroupNode) Extract

func (n *GroupNode) Extract(target reflect.Value) (err error)

Extract extracts group instance into target.

func (*GroupNode) Key

func (n *GroupNode) Key() Key

Key returns node unique identifier.

func (*GroupNode) Lifetime

func (n *GroupNode) Lifetime() Scope.ProviderLifetime

func (*GroupNode) Of

func (o *GroupNode) Of(k Key)

Of

func (*GroupNode) Out

func (o *GroupNode) Out() []Key

outTrait

func (*GroupNode) Replace

func (n *GroupNode) Replace(node *ProviderNode) (err error)

Replace replaces provider node in group.

type InstanceProvider

type InstanceProvider interface {
	Arguments
	Provide(arguments []reflect.Value) (reflect.Value, error)
	ResultType() reflect.Type
}

InstanceProvider ...

type InterfaceNode

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

InterfaceNode ...

func (*InterfaceNode) ArgumentNodes

func (n *InterfaceNode) ArgumentNodes() (args []Node)

ArgumentNodes return another nodes that included in this group. todo: Arguments() and ArgumentNodes() is too similar

func (*InterfaceNode) Arguments

func (n *InterfaceNode) Arguments() (args []Key)

Arguments returns another node keys that included in this group node.

func (*InterfaceNode) Extract

func (n *InterfaceNode) Extract(target reflect.Value) (err error)

Extract extracts node instance to target.

func (*InterfaceNode) Key

func (n *InterfaceNode) Key() Key

Key returns unique node identifier.

func (*InterfaceNode) Lifetime

func (n *InterfaceNode) Lifetime() Scope.ProviderLifetime

func (*InterfaceNode) Of

func (o *InterfaceNode) Of(k Key)

Of

func (*InterfaceNode) Out

func (o *InterfaceNode) Out() []Key

outTrait

type Key

type Key struct {
	Type reflect.Type
	Name string
}

Key unique identifier of node graph.

func (Key) String

func (k Key) String() string

String is a string representation of key.

type Node

type Node interface {
	Arguments
	ArgumentNodes() []Node
	Key() Key
	Extract(target reflect.Value) (err error)
	Out() []Key
	Of(k Key)
	Lifetime() Scope.ProviderLifetime
}

Node ...

type ProviderNode

type ProviderNode struct {
	InstanceProvider
	// contains filtered or unexported fields
}

ProviderNode ...

func NewProviderNode

func NewProviderNode(name string, lifetime Scope.ProviderLifetime, p InstanceProvider) (_ *ProviderNode)

NewProviderNode creates new provider node.

func (*ProviderNode) ArgumentNodes

func (n *ProviderNode) ArgumentNodes() (args []Node)

ArgumentNodes return another nodes that included in this group. todo: Arguments() and ArgumentNodes() is too similar

func (*ProviderNode) Extract

func (n *ProviderNode) Extract(target reflect.Value) (err error)

Extract extracts node into target.

func (*ProviderNode) Key

func (n *ProviderNode) Key() Key

Key returns unique node identifier.

func (*ProviderNode) Lifetime

func (n *ProviderNode) Lifetime() Scope.ProviderLifetime

func (*ProviderNode) Of

func (o *ProviderNode) Of(k Key)

Of

func (*ProviderNode) Out

func (o *ProviderNode) Out() []Key

outTrait

type Storage

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

Storage is a type graph storage implementation.

func NewStorage

func NewStorage() *Storage

NewStorage creates new storage.

func (*Storage) Add

func (s *Storage) Add(node Node, implements ...interface{}) (err error)

Add adds node to storage.

func (*Storage) All

func (s *Storage) All() (nodes []Node)

All returns all nodes.

func (*Storage) Compile

func (s *Storage) Compile() (err error)

Compile compiles the container.

func (*Storage) Extract

func (s *Storage) Extract(name string, target reflect.Value) (err error)

Extract extracts node instance into target.

func (*Storage) GroupNode

func (s *Storage) GroupNode(iface *InterfaceNode) (_ *GroupNode)

GroupNode returns or creates group node by interface.

func (*Storage) Replace

func (s *Storage) Replace(node Node, implements ...interface{}) (err error)

Replace node in a storage.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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