engine

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteFlowDefinition

func ExecuteFlowDefinition(
	flowInstance flow.Flow,
	initialInputs map[string]any,
	options *Options,
) (*spi.FlowExecutionResult, error)

Types

type ExecutionObserver

type ExecutionObserver interface {
	FlowStarted(evt FlowStartedEvent)
	NodeStarted(evt NodeStartedEvent)
	NodeFinished(evt NodeFinishedEvent)
	FlowFinished(evt FlowFinishedEvent)
}

type FlowEngine

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

func NewFlowEngine

func NewFlowEngine(flowInstance flow.Flow, options *Options) (*FlowEngine, error)

func (*FlowEngine) Execute

func (engine *FlowEngine) Execute(initialInputs map[string]any) (
	*spi.FlowExecutionResult, error,
)

type FlowFinishedEvent

type FlowFinishedEvent struct {
	FlowName   string
	StartedAt  time.Time
	FinishedAt time.Time
	DurationMs int64
	Result     *spi.FlowExecutionResult
}

type FlowStartedEvent

type FlowStartedEvent struct {
	FlowName  string
	StartedAt time.Time
}

type Middleware

type Middleware func(NodeExecutor) NodeExecutor

Middleware wraps a NodeExecutor to add cross-cutting behavior — retry, timeout, tracing, circuit-breaking — without baking it into node code. The first middleware in the slice is the outermost wrapper (it runs first / sees the final result last).

type NodeExecutor

type NodeExecutor func(spi.ExecutionContext) (spi.AnyResult, error)

NodeExecutor runs a single node and returns its result. It is the unit that Middleware wraps.

type NodeFinishedEvent

type NodeFinishedEvent struct {
	NodeID      string
	DisplayName string
	NodeType    spi.Kind
	StartedAt   time.Time
	FinishedAt  time.Time
	DurationMs  int64
	Result      spi.AnyResult
}

type NodeStartedEvent

type NodeStartedEvent struct {
	NodeID      string
	DisplayName string
	NodeType    spi.Kind
	StartedAt   time.Time
}

type NoopObserver

type NoopObserver struct{}

func (NoopObserver) FlowFinished

func (NoopObserver) FlowFinished(FlowFinishedEvent)

func (NoopObserver) FlowStarted

func (NoopObserver) FlowStarted(FlowStartedEvent)

func (NoopObserver) NodeFinished

func (NoopObserver) NodeFinished(NodeFinishedEvent)

func (NoopObserver) NodeStarted

func (NoopObserver) NodeStarted(NodeStartedEvent)

type Options

type Options struct {
	Observer        ExecutionObserver
	ModuleResolver  spi.ModuleResolver
	ModuleCallStack []string
	DynamicVars     spi.DynamicResolver
	// Ctx is the request-scoped context propagated to every node execution for
	// cancellation/deadlines. Nil is treated as context.Background().
	Ctx context.Context
	// Middleware wraps each node's execution (retry/timeout/tracing). Outermost first.
	Middleware []Middleware
}

Jump to

Keyboard shortcuts

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