engine

package
v0.210504.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: CC0-1.0 Imports: 15 Imported by: 0

Documentation

Overview

Engine tasks: - let drivers register actions - parse scenario .dot files - execute scenarios

Index

Constants

View Source
const ContextKey = "run/engine"
View Source
const FmtErrContext = "`%s`" // errors.Annotatef(err, FmtErrContext, doer.String())

Variables

View Source
var ErrArgNotApplied = errors.Errorf("Argument is not applied")
View Source
var ErrArgOverwrite = errors.Errorf("Argument already applied")

Functions

func IsNotResolved

func IsNotResolved(x interface{}) bool

Test `error` or `Doer` against ErrNotResolved

Types

type Arg

type Arg int32 // maybe interface{}

type ArgApplier

type ArgApplier interface {
	Apply(a Arg) (Doer, bool, error)
}

type Doer

type Doer interface {
	Validate() error
	Do(context.Context) error
	String() string // for logs
}

func ArgApply

func ArgApply(d Doer, arg Arg) (Doer, bool, error)

func Force

func Force(d Doer) (Doer, bool, error)

type Engine

type Engine struct {
	Log *log2.Log
	// contains filtered or unexported fields
}

func GetGlobal added in v0.201002.3

func GetGlobal(ctx context.Context) *Engine

func NewEngine

func NewEngine(log *log2.Log) *Engine

func (*Engine) Exec added in v0.200320.0

func (self *Engine) Exec(ctx context.Context, d Doer) error

func (*Engine) ExecList

func (self *Engine) ExecList(ctx context.Context, tag string, list []string) []error

func (*Engine) ExecPart added in v0.201002.3

func (self *Engine) ExecPart(ctx context.Context, d Doer) error

func (*Engine) List

func (self *Engine) List() []string

func (*Engine) ParseText

func (self *Engine) ParseText(tag, text string) (Doer, error)

func (*Engine) Register

func (self *Engine) Register(action string, d Doer)

func (*Engine) RegisterNewFunc

func (self *Engine) RegisterNewFunc(name string, fun func(context.Context) error)

func (*Engine) RegisterNewSeq

func (self *Engine) RegisterNewSeq(name string, ds ...Doer)

func (*Engine) RegisterParse

func (self *Engine) RegisterParse(name, scenario string) error

func (*Engine) Resolve

func (self *Engine) Resolve(action string) Doer

func (*Engine) ResolveOrLazy

func (self *Engine) ResolveOrLazy(action string) (Doer, error)

func (*Engine) SetProfile added in v0.201002.3

func (self *Engine) SetProfile(re *regexp.Regexp, min time.Duration, fun ProfileFunc)

re=nil or fun=nil to disable profiling.

func (*Engine) TestDo

func (e *Engine) TestDo(t testing.TB, ctx context.Context, name string)

func (*Engine) ValidateExec added in v0.201002.3

func (self *Engine) ValidateExec(ctx context.Context, d Doer) error

type ErrNotResolved

type ErrNotResolved struct {
	// contains filtered or unexported fields
}

func NewErrNotResolved

func NewErrNotResolved(action string) ErrNotResolved

func (ErrNotResolved) Error

func (e ErrNotResolved) Error() string

type Fail

type Fail struct{ E error }

func (Fail) Do

func (self Fail) Do(ctx context.Context) error

func (Fail) String

func (self Fail) String() string

func (Fail) Validate

func (self Fail) Validate() error

type Forcer

type Forcer interface{ Force() (Doer, bool, error) }

type Func

type Func struct {
	Name string
	F    func(context.Context) error
	V    ValidateFunc
}

func (Func) Do

func (self Func) Do(ctx context.Context) error

func (Func) String

func (self Func) String() string

func (Func) Validate

func (self Func) Validate() error

type Func0

type Func0 struct {
	Name string
	F    func() error
	V    ValidateFunc
}

func (Func0) Do

func (self Func0) Do(ctx context.Context) error

func (Func0) String

func (self Func0) String() string

func (Func0) Validate

func (self Func0) Validate() error

type FuncArg

type FuncArg struct {
	Name string
	F    func(context.Context, Arg) error
	V    ValidateFunc
	// contains filtered or unexported fields
}

func (FuncArg) Apply

func (fa FuncArg) Apply(a Arg) (Doer, bool, error)

func (FuncArg) Do

func (fa FuncArg) Do(ctx context.Context) error

func (FuncArg) String

func (fa FuncArg) String() string

func (FuncArg) Validate

func (fa FuncArg) Validate() error

type IgnoreArg

type IgnoreArg struct{ Doer }

func (IgnoreArg) Apply

func (self IgnoreArg) Apply(Arg) (Doer, bool, error)

type Lazy

type Lazy struct {
	Name string
	// contains filtered or unexported fields
}

func (*Lazy) Do

func (l *Lazy) Do(ctx context.Context) error

func (*Lazy) Force

func (l *Lazy) Force() (d Doer, forced bool, err error)

func (*Lazy) String

func (l *Lazy) String() string

func (*Lazy) Validate

func (l *Lazy) Validate() error

type MaybeBool

type MaybeBool uint8

type Nothing

type Nothing struct{ Name string }

func (Nothing) Do

func (self Nothing) Do(ctx context.Context) error

func (Nothing) String

func (self Nothing) String() string

func (Nothing) Validate

func (self Nothing) Validate() error

type ProfileFunc added in v0.201002.3

type ProfileFunc func(Doer, time.Duration)

type RepeatN

type RepeatN struct {
	N uint
	D Doer
}

func (RepeatN) Do

func (self RepeatN) Do(ctx context.Context) error

func (RepeatN) String

func (self RepeatN) String() string

func (RepeatN) Validate

func (self RepeatN) Validate() error

type RestartError

type RestartError struct {
	Doer
	Check func(error) bool
	Reset Doer
}

func (*RestartError) Apply

func (self *RestartError) Apply(arg Arg) (Doer, bool, error)

func (*RestartError) Do

func (self *RestartError) Do(ctx context.Context) error

func (*RestartError) String

func (self *RestartError) String() string

func (*RestartError) Validate

func (self *RestartError) Validate() error

type Run

type Run struct {
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner() *Run

func (*Run) Loop

func (r *Run) Loop(ctx context.Context, parent *alive.Alive)

func (*Run) Schedule

func (r *Run) Schedule(ctx context.Context, priority tele_api.Priority, fun types.TaskFunc) chan error

func (*Run) ScheduleSync

func (r *Run) ScheduleSync(ctx context.Context, priority tele_api.Priority, fun types.TaskFunc) error

type Seq

type Seq struct {
	// contains filtered or unexported fields
}

Sequence executor. Specialized version of Tree for performance. Error in one action aborts whole group. Build graph with NewSeq().Append()

func NewSeq

func NewSeq(name string) *Seq

func (*Seq) Append

func (seq *Seq) Append(d Doer) *Seq

func (*Seq) Apply

func (seq *Seq) Apply(arg Arg) (Doer, bool, error)

Apply makes copy of Seq, applying `arg` to exactly one (first) placeholder.

func (*Seq) Do

func (seq *Seq) Do(ctx context.Context) error

func (*Seq) Force

func (seq *Seq) Force() (Doer, bool, error)

func (*Seq) String

func (seq *Seq) String() string

func (*Seq) Validate

func (seq *Seq) Validate() error

type Sleep

type Sleep struct{ time.Duration }

func (Sleep) Do

func (self Sleep) Do(ctx context.Context) error

func (Sleep) String

func (self Sleep) String() string

func (Sleep) Validate

func (self Sleep) Validate() error

type ValidateFunc

type ValidateFunc func() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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