Documentation ¶
Overview ¶
Code for visiting nodes within a directed acyclic graph in dependency order.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Visit ¶
func Visit( ctx context.Context, startNodes []Node, dr DependencyResolver, v Visitor, resolverParallelism int, visitorParallelism int) (err error)
Call the visitor once for each unique node in the union of startNodes and all of its transitive dependencies, with bounded parallelism.
Guarantees:
If the graph contains a cycle, this function will not succeed.
If a node N depends on a node M, v.Visit(N) will be called only after v.Visit(M) returns successfully.
For each unique node N, dr.FindDependencies(N) and v.Visit(N) will each be called at most once. Moreover, v.Visit(N) will be called only after dr.FindDependencies(N) returns successfully.
Types ¶
type DependencyResolver ¶
type DependencyResolver interface { // Return a list of all unique direct dependencies of n within the DAG whose // structure is defined by this object. FindDependencies( ctx context.Context, n Node) (deps []Node, err error) }
A DependencyResolver knows how to find the direct dependencies of a node within a DAG.
type Node ¶
type Node interface{}
A value uniquely identifying a node within a DAG. A good choice is an integer, a string, or a pointer to a struct. The latter is useful for situations where a DependencyResolver or Visitor wants to modify state related to a node; the state can be changed without the pointer changing.
All nodes encountered within a call to one of this functions must be mutually comparable according to the Go spec.