Documentation
¶
Overview ¶
Package engine is orchestration only. Given one flow, it schedules nodes in dependency order, runs each node's declared assertion/output post-step, and recurses for sub-flows. It has no per-node-type logic: every kind is dispatched the same way. It records each node's outcome in a result.FlowResult and keeps going past a failure (skipping dependents) rather than aborting. The engine also satisfies node.SubflowRunner, so composite nodes recurse back into it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine runs flows.
func New ¶
New builds an engine. resolve looks up child flows by id (pass nil when the flow has no sub-flows). The engine wires itself in as the sub-flow runner.
func (*Engine) RunFlow ¶
RunFlow executes a flow and returns its full result. Node failures are recorded in the result (Success=false), not returned as an error.
type Event ¶
type Event struct {
Type spi.EventType
NodeID string
Node *result.NodeResult
Flow *result.FlowResult
}
Event is an execution event emitted during a top-level flow run. Node carries the node's result for node.* events; Flow carries the flow result for flow.* events.
A node that runs a sub-flow (module/loop/poll body) emits as one node event — its inner nodes are silent. This keeps the wire flat and re-running bodies (poll/loop) from storming events. If nested progress is ever needed, add depth to Event rather than un-silencing the recursion.
type Middleware ¶
Middleware wraps a NodeExec. The engine chains them outermost-first around every node.
func Retry ¶
func Retry(attempts int) Middleware
Retry re-runs a node up to attempts times while it errors (including on an assertion failure), pausing a short ctx-respecting backoff between attempts. attempts <= 1 disables retry.
func Timeout ¶
func Timeout(d time.Duration) Middleware
Timeout bounds each node's execution with a per-node deadline.
type NodeExec ¶
NodeExec is a node's run-and-assert unit — the innermost thing middleware wraps. Wrapping this (rather than just Execute) means retry re-runs the assertion pass too, matching the old runner's semantics.
type Observer ¶
type Observer func(Event)
Observer receives execution events (progress streaming). It must be safe to call synchronously from the engine.
type Option ¶
type Option func(*Engine)
Option configures an Engine at construction.
func WithMiddleware ¶
func WithMiddleware(mw ...Middleware) Option
WithMiddleware wraps every node's run-and-assert unit (e.g. Retry, Timeout).
func WithObserver ¶
WithObserver attaches an execution-event observer (top-level flow only).