engine

package
v0.241210.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: CC0-1.0 Imports: 12 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")
	ErrArgOverwrite  = errors.Errorf("Argument already applied")
)

Functions

func IsNotResolved

func IsNotResolved(x interface{}) bool

IsNotResolved Test `error` or `Doer` against ErrNotResolved

Types

type Arg

type Arg 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

func GetGlobal(ctx context.Context) *Engine

func NewEngine

func NewEngine(log *log2.Log) *Engine

func (*Engine) Exec

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

func (*Engine) ExecList

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

func (*Engine) ExecPart

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

func (*Engine) List

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

func (*Engine) ParseText

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

func (*Engine) Register

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

func (*Engine) RegisterNewFunc

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

func (*Engine) RegisterNewFuncAgr added in v0.230424.2

func (e *Engine) RegisterNewFuncAgr(name string, fun func(ctx context.Context, arg Arg) error)

func (*Engine) RegisterNewSeq

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

func (*Engine) RegisterParse

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

func (*Engine) Resolve

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

func (*Engine) ResolveOrLazy

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

func (*Engine) SetProfile

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

SetProfile 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

func (e *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 (f Fail) Do(ctx context.Context) error

func (Fail) String

func (f Fail) String() string

func (Fail) Validate

func (f 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 (f Func) Do(ctx context.Context) error

func (Func) String

func (f Func) String() string

func (Func) Validate

func (f Func) Validate() error

type Func0

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

func (Func0) Do

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

func (Func0) String

func (f Func0) String() string

func (Func0) Validate

func (f 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 (i 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 (n Nothing) Do(ctx context.Context) error

func (Nothing) String

func (n Nothing) String() string

func (Nothing) Validate

func (n Nothing) Validate() error

type ProfileFunc

type ProfileFunc func(Doer, time.Duration)

type RepeatN

type RepeatN struct {
	N uint
	D Doer
}

func (RepeatN) Do

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

func (RepeatN) String

func (r RepeatN) String() string

func (RepeatN) Validate

func (r RepeatN) Validate() error

type RestartError

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

func (*RestartError) Apply

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

func (*RestartError) Do

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

func (*RestartError) String

func (re *RestartError) String() string

func (*RestartError) Validate

func (re *RestartError) Validate() 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 (s Sleep) Do(ctx context.Context) error

func (Sleep) String

func (s Sleep) String() string

func (Sleep) Validate

func (s 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