graph

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: MIT Imports: 4 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 added in v1.3.0

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 added in v1.3.0

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 added in v1.3.0

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) Of added in v1.4.1

func (o *GroupNode) Of(k Key)

Of

func (*GroupNode) Out added in v1.4.1

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 added in v1.2.0

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 added in v1.3.0

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 added in v1.3.0

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) Of added in v1.4.1

func (o *InterfaceNode) Of(k Key)

Of

func (*InterfaceNode) Out added in v1.4.1

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

outTrait

type Key added in v1.2.0

type Key struct {
	Type reflect.Type
	Name string
}

Key unique identifier of node graph.

func (Key) String added in v1.2.0

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)
}

Node ...

type ProviderNode

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

ProviderNode ...

func NewProviderNode

func NewProviderNode(name string, p InstanceProvider) (_ *ProviderNode)

NewProviderNode creates new provider node.

func (*ProviderNode) ArgumentNodes added in v1.3.0

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) Of added in v1.4.1

func (o *ProviderNode) Of(k Key)

Of

func (*ProviderNode) Out added in v1.4.1

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 added in v1.3.0

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