Documentation
¶
Index ¶
- Variables
- type Errors
- type Graph
- func (g *Graph) AddTask(t *Task)
- func (g *Graph) DephFirstSort() ([]*Vertex, error)
- func (g *Graph) Run(ctx context.Context, opt *getoptions.GetOpt, args []string) error
- func (g *Graph) SetSerial() *Graph
- func (g *Graph) String() string
- func (g *Graph) Task(id string) *Task
- func (g *Graph) TaskDependensOn(t *Task, tDependencies ...*Task)
- func (g *Graph) Validate(tm *TaskMap) error
- type ID
- type Task
- type TaskMap
- type Vertex
Constants ¶
This section is empty.
Variables ¶
var ErrorGraphHasCycle = fmt.Errorf("graph has a cycle")
var ErrorSkipParents = fmt.Errorf("skip parents without failing")
ErrorSkipParents - Allows for conditional tasks that allow a task to Skip all parent tasks without failing the run
var ErrorTaskDependencyDuplicate = fmt.Errorf("task dependency already defined")
var ErrorTaskDuplicate = fmt.Errorf("task definition already exists")
var ErrorTaskFn = fmt.Errorf("missing task function")
var ErrorTaskID = fmt.Errorf("missing task ID")
var ErrorTaskNil = fmt.Errorf("nil task given")
var ErrorTaskNotFound = fmt.Errorf("task not found")
var ErrorTaskSkipped = fmt.Errorf("skipped")
Functions ¶
This section is empty.
Types ¶
type Graph ¶
type Graph struct {
Name string
TickerDuration time.Duration
Vertices map[ID]*Vertex
// contains filtered or unexported fields
}
func (*Graph) DephFirstSort ¶
DephFirstSort - Returns a sorted list with the Vertices https://en.wikipedia.org/wiki/Topological_sorting#Depth-first_search It returns ErrorGraphHasCycle is there are cycles.
func (*Graph) Run ¶
Run - Execute the graph tasks in parallel where possible. It checks for tasks updates every 1 Millisecond by default. Modify using the graph.TickerDuration
func (*Graph) SetSerial ¶
SetSerial - The call to Run() will run the Tasks serially. Useful when the tasks require user input and the user needs to see logs in order to make a decision.
func (*Graph) TaskDependensOn ¶
TaskDependensOn - Allows adding tasks to the graph and defining their edges.
type Task ¶
type Task struct {
ID ID
Fn getoptions.CommandFn
// contains filtered or unexported fields
}
type TaskMap ¶
type TaskMap struct {
// contains filtered or unexported fields
}
func (*TaskMap) Add ¶
func (tm *TaskMap) Add(id string, fn getoptions.CommandFn) *Task
Add - Adds a new task to the TaskMap. Errors collected for TaskMap.Validate().