scheduler

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2020 License: GPL-3.0 Imports: 11 Imported by: 2

Documentation

Index

Examples

Constants

View Source
const (
	StatusWaiting = iota
	StatusRunning
	StatusSkipped
	StatusDone
	StatusError
	StatusCanceled
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecutionGraph

type ExecutionGraph struct {
	Env map[string][]string
	// contains filtered or unexported fields
}

func NewExecutionGraph

func NewExecutionGraph(stages ...*Stage) (*ExecutionGraph, error)

func (*ExecutionGraph) AddEdge

func (g *ExecutionGraph) AddEdge(from string, to string) error

func (*ExecutionGraph) AddNode

func (g *ExecutionGraph) AddNode(name string, stage *Stage)

func (*ExecutionGraph) AddStage

func (g *ExecutionGraph) AddStage(stage *Stage) error

func (*ExecutionGraph) Error

func (g *ExecutionGraph) Error() error

func (*ExecutionGraph) From

func (g *ExecutionGraph) From(name string) []string

func (*ExecutionGraph) Node

func (g *ExecutionGraph) Node(name string) (*Stage, error)

func (*ExecutionGraph) Nodes

func (g *ExecutionGraph) Nodes() map[string]*Stage

func (*ExecutionGraph) To

func (g *ExecutionGraph) To(name string) []string

type Scheduler

type Scheduler struct {
	Start time.Time
	End   time.Time
	// contains filtered or unexported fields
}

func NewScheduler

func NewScheduler(r runner.Runner) *Scheduler

func (*Scheduler) Cancel

func (s *Scheduler) Cancel()

func (*Scheduler) Finish

func (s *Scheduler) Finish()

func (*Scheduler) Schedule

func (s *Scheduler) Schedule(g *ExecutionGraph) error
Example
format := task.FromCommands("go fmt ./...")
build := task.FromCommands("go build ./..")
r, _ := runner.NewTaskRunner()
s := NewScheduler(r)

graph, err := NewExecutionGraph(
	&Stage{Name: "format", Task: format},
	&Stage{Name: "build", Task: build, DependsOn: []string{"format"}},
)
if err != nil {
	return
}

err = s.Schedule(graph)
if err != nil {
	fmt.Println(err)
}

type Stage

type Stage struct {
	Name         string
	Condition    string
	Task         *task.Task
	Pipeline     *ExecutionGraph
	DependsOn    []string
	Dir          string
	AllowFailure bool
	Status       int32
	Env          variables.Container
	Variables    variables.Container

	Start time.Time
	End   time.Time
}

func (*Stage) Duration

func (s *Stage) Duration() time.Duration

func (*Stage) ReadStatus

func (s *Stage) ReadStatus() int32

func (*Stage) UpdateStatus

func (s *Stage) UpdateStatus(status int32)

Jump to

Keyboard shortcuts

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