Documentation
¶
Index ¶
- Constants
- Variables
- func AssociateChildren(subject Relationship, children ...Relationship)
- func AssociateParents(subject Relationship, parents ...Relationship)
- func HasChild(host Relationship, question Relationship) bool
- func HasIndirectChild(host Relationship, question Relationship) bool
- func HasIndirectParent(host Relationship, question Relationship) bool
- func HasParent(host Relationship, question Relationship) bool
- func WalkRelationship(base Relationship, maxdepth int, offset int, direction WalkDirection, ...) error
- type DotNode
- type DotWriter
- type Hasher
- type ItemGraph
- type Node
- type NodeQueue
- type Relationship
- type RelationshipWalkFunc
- type WalkDirection
Constants ¶
const ( // InfiniteDepth is used as a flag to instruct the walker to traverse infinite depth InfiniteDepth int = -1 // TraverseChildren is a flag to denote the Relationship should walk children TraverseChildren WalkDirection = iota // TraverseParents is a flag to denote the Relationship should walk parents TraverseParents )
Variables ¶
var ( // ErrTraversalPathEnded is thrown when the walker has hit the final element in the tree ErrTraversalPathEnded = errors.New("traversal path has hit the final element") // ErrRelationshipWalkHalted is thrown when a walk is intended to discontinue walking ErrRelationshipWalkHalted = errors.New("relationship walk has reached a termination point") // ErrWalkDirectionUndefined is thrown when a direction is neither TraverseChildren or TraverseParents ErrWalkDirectionUndefined = errors.New("a walk direction of an unknown type has been given") )
Functions ¶
func AssociateChildren ¶
func AssociateChildren(subject Relationship, children ...Relationship)
AssociateChildren is a generic function to associate child dependencies with an object
func AssociateParents ¶
func AssociateParents(subject Relationship, parents ...Relationship)
AssociateParents is a generic function to associate parent dependencies with an object
func HasChild ¶
func HasChild(host Relationship, question Relationship) bool
HasChild determines if a direct child relationship exists between host (parent) and question (supposed child)
func HasIndirectChild ¶
func HasIndirectChild(host Relationship, question Relationship) bool
HasIndirectChild determines if a transitive parent relationship exists between host (parent) and question (supposed child)
func HasIndirectParent ¶
func HasIndirectParent(host Relationship, question Relationship) bool
HasIndirectParent determines if a transitive parent relationship exists between host (child) and question (supposed parent)
func HasParent ¶
func HasParent(host Relationship, question Relationship) bool
HasParent determines if a direct parent relationship exists between host (child) and question (supposed parent)
func WalkRelationship ¶
func WalkRelationship(base Relationship, maxdepth int, offset int, direction WalkDirection, walkFunc RelationshipWalkFunc) error
WalkRelationship is a recursive walk similar to filepath.Walk except it traverses relationships
Types ¶
type DotWriter ¶
DotWriter is a type that will build the DOT syntax of our Metadata
func NewDotWriter ¶
NewDotWriter creates a new writer to generate DOT graphs
func (*DotWriter) PlotGraph ¶
func (dw *DotWriter) PlotGraph(root Relationship)
PlotGraph traverses the root Relationship (root) while DotWriter.MaxDepth > 0, generating the graph.
type Hasher ¶
type Hasher interface {
Hash() uint64
}
Hasher is an interface to allow types to be checksumed for potentially build breaking changes
type ItemGraph ¶
type ItemGraph struct {
// contains filtered or unexported fields
}
ItemGraph the Items graph
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node a single node that composes the tree
type NodeQueue ¶
type NodeQueue struct {
// contains filtered or unexported fields
}
NodeQueue the queue of Nodes
type Relationship ¶
type Relationship interface {
Hasher
DotNode
GetID() string
Children() []Relationship
Parents() []Relationship
ParentIDs() []string
ChildrenIDs() []string
AddChild(r ...Relationship)
AddParent(r ...Relationship)
}
Relationship is an interface to allow core objects to build relationships between them
type RelationshipWalkFunc ¶
type RelationshipWalkFunc func(rel Relationship, distance int) error
RelationshipWalkFunc allows for recursive relation traversal
type WalkDirection ¶
type WalkDirection int
WalkDirection allows the directon of the walk to be specified