runner

package
v1.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2024 License: Apache-2.0 Imports: 2 Imported by: 4

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 Artifact added in v1.18.0

type Artifact struct {
	Image   string `json:"image"`
	User    string `json:"user"`
	Pass    string `json:"pass"`
	Cleanup bool   `json:"cleanup"`
}

type File added in v1.9.0

type File struct {
	Content string
	Gzip    bool
}

type Language added in v1.17.0

type Language struct {
	Name     string   `json:"name"`
	Artifact Artifact `json:"artifact"`
}

type Line added in v1.2.0

type Line struct {
	Pos     int64
	Time    int64
	Message string
}

type Log added in v1.16.0

type Log struct {
	Line chan *Line
}

type Param added in v1.13.0

type Param struct {
	Name  string
	Value string
}

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

func (r *Runner) AddEdge(from, to string)

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

func (r *Runner) Run(log Log) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL