Documentation ¶
Overview ¶
Package runner implements a directed acyclic graph task runner with deterministic teardown. it is similar to package errgroup, in that it runs multiple tasks in parallel and returns the first error it encounters. Users define a Runner as a set vertices (functions) and edges between them. During Run, the directed acyclec graph will be validated and each vertex will run in parallel as soon as it's dependencies have been resolved. The Runner will only return after all running goroutines have stopped.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner collects functions and arranges them as vertices and edges of a directed acyclic graph. Upon validation of the graph, functions are run in parallel topological order. The zero value is useful.
func (*Runner) AddEdge ¶
AddEdge establishes a dependency between two vertices in the graph. Both from and to must exist in the graph, or Run will err. The vertex at from will execute before the vertex at to.
func (*Runner) AddVertex ¶
func (r *Runner) AddVertex(name string, fn func(string, File, []Param, []string, int64, Language, Log) error, file File, envs []Param, args []string, width int64, lang Language)
AddVertex adds a function as a vertex in the graph. Only functions which have been added in this way will be executed during Run.
func (*Runner) Run ¶
Run will validate that all edges in the graph point to existing vertices, and that there are no dependency cycles. After validation, each vertex will be run, deterministically, in parallel topological order. If any vertex returns an error, no more vertices will be scheduled and Run will exit and return that error once all in-flight functions finish execution.