executor

package
v0.0.0-...-21d01d2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyWorkflow is the error when the given workflow is nil or does not have any steps.
	ErrEmptyWorkflow = errors.New("workflow is empty")

	// ErrMultipleInputs is the error when a workflow has multiple steps without parent dependencies
	ErrMultipleInputs = errors.New("workflow must have only one entrypoint step")
)

Functions

This section is empty.

Types

type ExecutionMonitor

type ExecutionMonitor interface {
	// HandleResults handles the given workflow execution result.
	HandleResults(ctx context.Context, result *Result)
}

ExecutionMonitor represents a behavior of the workflow execution monitor that handles results during the execution. Should be implemented per business requirements.

type Executor

type Executor interface {
	// Execute executes the given workflow and returns a results.
	Execute(ctx context.Context, wf *workflow.Workflow, store cache.Cache) error

	// Serve started serving the given workflow.
	// Returns cancellation function or error
	Serve(ctx context.Context, wf *workflow.Workflow) (func(), error)
}

Executor describes a behavior of the workflow executor interface.

func New

func New(
	logger logrus.FieldLogger,
	provider onchain.Provider,
	keystore keystore.KeyStore,
	broadcaster broadcaster.Broadcaster,
	monitor ExecutionMonitor,
) Executor

New is the constructor of defaultExecutor

type Result

type Result struct {
	WorkflowID    string
	Store         cache.Cache
	StepsLock     sync.Mutex
	Steps         map[string]StepResult
	ExecutionTime time.Duration
	Error         error
}

Result is the workflow execution result.

func (*Result) AddStepResult

func (r *Result) AddStepResult(id string, result StepResult)

AddStepResult adds the given step execution result to the list

type StepResult

type StepResult struct {
	ExecutionTime time.Duration
	Store         cache.Cache
	Error         error
}

Jump to

Keyboard shortcuts

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