Documentation
¶
Overview ¶
Package dag provides generic graph algorithms that work with any data structure, and the renderers that draw a workflow's jobs as a graph.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectCycleFn ¶
func DetectCycleFn[ID comparable](allIDs []ID, getDeps func(ID) []ID) []ID
DetectCycleFn detects a cycle in a graph using a higher-order function. Returns the cycle path if found, nil otherwise.
Parameters:
- allIDs: All node identifiers in the graph
- getDeps: Function that returns dependencies (children) for a given node
Example:
getDeps := func(id string) []string {
switch id {
case "A": return []string{"B", "C"}
case "B": return []string{"C"}
default: return nil
}
}
cycle := DetectCycleFn([]string{"A", "B", "C"}, getDeps)
Types ¶
type ASCII ¶
type ASCII struct{}
ASCII draws a Graph as boxes of jobs and their steps, joined by lines from each job to the jobs that need it.
type Graph ¶
type Graph struct {
Jobs []Job
}
Graph is what a workflow's DAG is drawn from: its jobs in declaration order, the steps of each, and the jobs each one needs.
type Job ¶
type Job struct {
// ID identifies the job in other jobs' Needs. It is the job's id, or its
// name when it has none.
ID string
Name string
Needs []string
Steps []Step
}
Job is one node of a Graph.
type Mermaid ¶
type Mermaid struct{}
Mermaid draws a Graph as a Mermaid flowchart: a subgraph for each job with its steps linked in run order, and an edge from each job to the jobs that need it.
type Step ¶
type Step struct {
// Name is the step's name, or the action it uses when it has none.
Name string
// Embedded is set for a step that runs a job from another file.
Embedded bool
// EmbeddedFile is the base name of that file, and EmbeddedSteps the names
// of its steps. Both are empty when the file could not be read or has no
// steps.
EmbeddedFile string
EmbeddedSteps []string
}
Step is one step of a Job.