Documentation
¶
Overview ¶
Package depend provides the core data types for the buildtime dependency injection system.
Index ¶
- Variables
- type Container
- func (c *Container) AddFunc(function *types.Func) error
- func (c *Container) Edge(u graph.Node, v graph.Node) graph.Edge
- func (c *Container) From(node graph.Node) []graph.Node
- func (c *Container) Has(node graph.Node) bool
- func (c *Container) HasEdgeBetween(x graph.Node, y graph.Node) bool
- func (c *Container) HasEdgeFromTo(u graph.Node, v graph.Node) bool
- func (c *Container) Nodes() []graph.Node
- func (c *Container) Root() (graph.Node, error)
- func (c *Container) To(node graph.Node) []graph.Node
- type Error
- type InvalidFuncError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoRoot is the error used to indicate a root has not been // set on a Container for an operation that requires such a root. ErrNoRoot = errors.New("no root set for container") // ErrRootAlreadySet is the error used to indicate that a root has // already been set on a Container for an operation that only allows // the root to be set once. ErrRootAlreadySet = errors.New("root already set for container") // ErrAmbiguousRootDetected is the error used to indicate that an attempt // to auto-detect the root has found more than one root candidate. ErrAmbiguousRootDetected = errors.New("root auto-detection found ambiguous root candidates") )
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
A Container exposes the dependencies implicit in set of constructors or static factories as a directed graph.Container implements the graph.Directed interface from github.com/gonum/graph.
func (*Container) AddFunc ¶
AddFunc adds function to the Container. function should be a constructor or other static factory. The non-error return types of function are made available as components that can satisfy the components required by other functions added to the container. The parameters to the function are required to be satisfied by components in the Container for the Container to be complete. function can have an error return type as its last return type.
AddFunc will auto-detect root types that are provided by function. A root type for this purpose is a types.Type whose method set includes a nullary method named "Run". AddFunc will return an error if it auto-detects a second root type for the Container.
AddFunc will return an InvalidFuncError for a function with an error return type in any position except the last. It will also return an InvalidFuncError if a method is passed in as function.
func (*Container) Edge ¶
Edge returns the edge from u to v if such an edge exists and nil otherwise. The node v must be directly reachable from u as defined by the From method.
func (*Container) HasEdgeBetween ¶
HasEdgeBetween returns whether an edge exists between nodes x and y without considering the direction.
func (*Container) HasEdgeFromTo ¶
HasEdgeFromTo returns whether an edge exists in the Container from u to v.
type Error ¶
type Error interface { error // Pos returns the position associated with this error. Pos() token.Pos // ErrorWithPosition returns the error message for the error preceded with // the string representation of the position as given by the token.FileSet. ErrorWithPosition(fileSet *token.FileSet) string }
An Error represents an error with an associated position in an implicit token.FileSet.
type InvalidFuncError ¶
type InvalidFuncError struct {
// contains filtered or unexported fields
}
InvalidFuncError records an error with an attempt to add an invalid types.Func to a Container. InvalidFuncError implements Error.
func (*InvalidFuncError) Error ¶
func (ife *InvalidFuncError) Error() string
func (*InvalidFuncError) ErrorWithPosition ¶
func (ife *InvalidFuncError) ErrorWithPosition(fileSet *token.FileSet) string
func (*InvalidFuncError) Pos ¶
func (ife *InvalidFuncError) Pos() token.Pos