task

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotTask = errors.New("not a task")
)

Functions

func LookupAction

func LookupAction(v *cue.Value) (string, *cue.Value)

lookup action type in cue

func Register

func Register(typ string, f NewFunc)

Register a task type and initializer

func Then

func Then(ctx context.Context, v *cue.Value) error

do then action

Types

type NewFunc

type NewFunc func() Task

type State

type State int8

State is the state of the task.

const (
	// state order is important here since it defines the  order
	// on how states can transition only forwards
	// computing > completed > canceled > failed
	StateComputing State = iota
	StateSkipped
	StateCompleted
	StateCanceled
	StateFailed
)

func ParseState

func ParseState(s string) (State, error)

func (State) CanTransition

func (s State) CanTransition(t State) bool

func (State) String

func (s State) String() string

type Task

type Task interface {
	Run(ctx context.Context, v *cue.Value) (*cue.Value, error)
	Name() string
}

return result

func Lookup

func Lookup(v *cue.Value) (Task, error)

find action type by path

func New

func New(typ string) Task

New creates a new Task of the given type.

Jump to

Keyboard shortcuts

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