Documentation ¶
Index ¶
- func AreSiblingIDs(a, b string) bool
- func BaseID(id string) string
- func ID(parts ...string) string
- func IsDescendentID(parent, child string) bool
- func ParentID(id string) string
- func SiblingID(id, sibling string) string
- func SkipModuleAndParams(id string) bool
- func Sources(edges []dag.Edge) (sources []string)
- func Targets(edges []dag.Edge) (targets []string)
- type Edge
- type Graph
- func (g *Graph) Add(id string, value interface{})
- func (g *Graph) Connect(from, to string)
- func (g *Graph) ConnectParent(from, to string)
- func (g *Graph) Contains(id string) bool
- func (g *Graph) Copy() *Graph
- func (g *Graph) Dependencies(id string) []string
- func (g *Graph) Descendents(id string) (out []string)
- func (g *Graph) Disconnect(from, to string)
- func (g *Graph) DownEdges(id string) (out []dag.Edge)
- func (g *Graph) Edges() []Edge
- func (g *Graph) Get(id string) interface{}
- func (g *Graph) GetParent(id string) interface{}
- func (g *Graph) MaybeGet(id string) (interface{}, bool)
- func (g *Graph) Remove(id string)
- func (g *Graph) Root() (string, error)
- func (g *Graph) RootFirstTransform(ctx context.Context, cb TransformFunc) (*Graph, error)
- func (g *Graph) RootFirstWalk(ctx context.Context, cb WalkFunc) error
- func (g *Graph) String() string
- func (g *Graph) Transform(ctx context.Context, cb TransformFunc) (*Graph, error)
- func (g *Graph) UpEdges(id string) (out []dag.Edge)
- func (g *Graph) Validate() error
- func (g *Graph) Vertices() []string
- func (g *Graph) Walk(ctx context.Context, cb WalkFunc) error
- type Notifier
- type ParentEdge
- type PostNotifyFunc
- type PreNotifyFunc
- type SkipMergeFunc
- type TransformFunc
- type WalkFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AreSiblingIDs ¶
AreSiblingIDs checks if two IDs are siblings
func IsDescendentID ¶
IsDescendentID checks if a child is the descendent of a given parent
func SkipModuleAndParams ¶
SkipModuleAndParams skips trimming modules and params
Types ¶
type Edge ¶
type Edge struct { Source string `json:"source"` Dest string `json:"dest"` Attributes []string `json:"attributes"` }
An Edge is a generic pair of IDs indicating a directed edge in the graph
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph is a generic graph structure that uses IDs to connect the graph
func MergeDuplicates ¶
MergeDuplicates removes duplicates in the graph
func (*Graph) ConnectParent ¶
ConnectParent connects a parent node to a child node
func (*Graph) Dependencies ¶
Dependencies gets a list of all dependencies without relying on the ID functions and will work for dependencies that have been added during load.ResolveDependencies
func (*Graph) Descendents ¶
Descendents gets a list of all descendents (not just children, everything) This only works if you're using the hierarchical ID functions from this module.
func (*Graph) Disconnect ¶
Disconnect two vertices by IDs
func (*Graph) MaybeGet ¶
MaybeGet returns the value of the element and a bool indicating if it was found, if it was not found the value of the returned element is nil.
func (*Graph) RootFirstTransform ¶
RootFirstTransform does Transform, but starting at the root
func (*Graph) RootFirstWalk ¶
RootFirstWalk walks the graph root-to-leaf, checking sibling dependencies before descending.
func (*Graph) Transform ¶
Transform a graph of type A to a graph of type B. A and B can be the same.
func (*Graph) Validate ¶
Validate that the graph...
1. has a root 2. has no cycles 3. has no dangling edges
type Notifier ¶
type Notifier struct { Pre PreNotifyFunc Post PostNotifyFunc }
Notifier can wrap a graph transform
func (*Notifier) Transform ¶
func (n *Notifier) Transform(inner TransformFunc) TransformFunc
Transform wraps a TransformFunc with this notifier
type ParentEdge ¶
ParentEdge marks an edge as signifying a parent/child relationship
func NewParentEdge ¶
func NewParentEdge(parent, child string) *ParentEdge
NewParentEdge constructs a new ParentEdge between the given vertices
type PostNotifyFunc ¶
PostNotifyFunc will be called after planning
type PreNotifyFunc ¶
PreNotifyFunc will be called before execution
type SkipMergeFunc ¶
SkipMergeFunc will be used to determine whether or not to merge a node
type TransformFunc ¶
TransformFunc is taken by the transformation functions
func NotifyPost ¶
func NotifyPost(post PostNotifyFunc, inner TransformFunc) TransformFunc
NotifyPost will call a function after walking a node
func NotifyPre ¶
func NotifyPre(pre PreNotifyFunc, inner TransformFunc) TransformFunc
NotifyPre will call a function before walking a node