Documentation
¶
Overview ¶
The depgraph package is used to create and model a dependency graph of nouns. Each noun can represent a service, server, application, network switch, etc. Nouns can depend on other nouns, and provide versioning constraints. Nouns can also have various meta data that may be relevant to their construction or configuration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Constraint ¶
type Constraint interface {
Satisfied(head, tail *Noun) (bool, error)
}
Constraint is used by dependencies to allow arbitrary constraints between nouns
type ConstraintError ¶
type ConstraintError struct {
Violations []*Violation
}
ConstraintError is used to return detailed violation information from CheckConstraints
type Dependency ¶
type Dependency struct {
Name string
Meta interface{}
Constraints []Constraint
Source *Noun
Target *Noun
}
Dependency is used to create a directed edge between two nouns. One noun may depend on another and provide version constraints that cannot be violated
type Graph ¶
type Graph struct {
Name string
Meta interface{}
Nouns []*Noun
Root *Noun
}
Graph is used to represent a dependency graph.
func (*Graph) CheckConstraints ¶
func (g *Graph) CheckConstraints() error
CheckConstraints walks the graph and ensures that all user imposed constraints are satisfied.
func (*Graph) DependsOn ¶ added in v0.3.0
func (g *Graph) DependsOn(n *Noun) []*Noun
DependsOn returns the set of nouns that have a dependency on a given noun. This can be used to find the incoming edges to a noun.
func (*Graph) Noun ¶
func (g *Graph) Noun(name string) *Noun
Noun returns the noun with the given name, or nil if it cannot be found.
func (*Graph) String ¶
func (g *Graph) String() string
String generates a little ASCII string of the graph, useful in debugging output.
func (*Graph) Validate ¶
func (g *Graph) Validate() error
Validate is used to ensure that a few properties of the graph are not violated: 1) There must be a single "root", or source on which nothing depends. 2) All nouns in the graph must be reachable from the root 3) The graph must be cycle free, meaning there are no cicular dependencies
type Noun ¶
type Noun struct {
Name string // Opaque name
Meta interface{}
Deps []*Dependency
}
Nouns are the key structure of the dependency graph. They can be used to represent all objects in the graph. They are linked by depedencies.
type ValidateError ¶
type ValidateError struct {
// If set, then the graph is missing a single root, on which
// there are no depdendencies
MissingRoot bool
// Unreachable are nodes that could not be reached from
// the root noun.
Unreachable []*Noun
// Cycles are groups of strongly connected nodes, which
// form a cycle. This is disallowed.
Cycles [][]*Noun
}
ValidateError implements the Error interface but provides additional information on a validation error.