workgraph

package
v0.0.0-...-f305919 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Source = 0
	Sink   = 1
)

Variables

View Source
var ErrBadState = errors.New("state transition not allowed")
View Source
var ErrNoItems = errors.New("no items found")

Functions

This section is empty.

Types

type Item

type Item struct {
	ID     int
	Task   *pb.Task
	Worker string

	State     State
	DependsOn []Relation
}

func (*Item) Ready

func (item *Item) Ready() bool

type Relation

type Relation struct {
	State  State
	Target *Item
}

type State

type State int32
const (
	Waiting State = iota + 1
	Scheduled
	InProgress
	Failed
	Done
)

func (State) Matches

func (s State) Matches(t State) bool

func (State) String

func (s State) String() string

type WorkGraph

type WorkGraph struct {
	Items []*Item
}

func New

func New() *WorkGraph

func (*WorkGraph) AddItem

func (wg *WorkGraph) AddItem(item *Item) int

func (*WorkGraph) AddRelation

func (wg *WorkGraph) AddRelation(item int, state State, dependency int)

func (*WorkGraph) BeginItem

func (wg *WorkGraph) BeginItem(item int) error

func (*WorkGraph) CanSchedule

func (wg *WorkGraph) CanSchedule(worker string) (*Item, error)

func (*WorkGraph) FailItem

func (wg *WorkGraph) FailItem(item int) error

func (*WorkGraph) FinishItem

func (wg *WorkGraph) FinishItem(item int) error

func (*WorkGraph) Graphviz

func (wg *WorkGraph) Graphviz() []byte

func (*WorkGraph) Schedule

func (wg *WorkGraph) Schedule(worker string) (*Item, error)

Jump to

Keyboard shortcuts

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