Documentation
¶
Overview ¶
Package runner is the single entrypoint for executing a flow. Every transport — the in-process cloud control plane, the self-hosted job runner, and the ephemeral CLI — drives execution through Run so the orchestration (input merge, referenced-flow module resolution, engine wiring) lives in exactly one place. Transports differ only in their Observer (where progress events go) and in how they serialize the returned result.
Index ¶
- func MergeInputs(base, override map[string]any) map[string]any
- func ModuleResolver(refs flow.ReferencedFlowRegistry) spi.ModuleResolver
- func Retry(attempts int) engine.Middleware
- func Run(flowDef flow.Flow, inputs map[string]any, opts ...Option) (*spi.FlowExecutionResult, error)
- func Timeout(d time.Duration) engine.Middleware
- type Option
- func WithContext(ctx context.Context) Option
- func WithDynamicVars(d spi.DynamicResolver) Option
- func WithMiddleware(middleware ...engine.Middleware) Option
- func WithModuleCallStack(stack []string) Option
- func WithObserver(obs engine.ExecutionObserver) Option
- func WithReferencedFlows(refs flow.ReferencedFlowRegistry) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MergeInputs ¶
MergeInputs overlays override onto base, returning a new map. base values fill keys the caller did not provide (e.g. flow-declared defaults); override wins.
func ModuleResolver ¶
func ModuleResolver(refs flow.ReferencedFlowRegistry) spi.ModuleResolver
ModuleResolver builds a spi.ModuleResolver from referenced flows. Returns nil when there are none, which the engine treats as "no module targets". This is the single implementation; it replaces the copies that lived in the cloud, self-hosted, and ephemeral transports.
func Retry ¶
func Retry(attempts int) engine.Middleware
Retry re-runs a node up to attempts times while it returns an error, stopping early if the execution context is cancelled. attempts < 1 is treated as 1.
func Run ¶
func Run(flowDef flow.Flow, inputs map[string]any, opts ...Option) (*spi.FlowExecutionResult, error)
Run executes flowDef. It overlays inputs on the flow's declared InitialInputs (inputs win), resolves referenced flows into the module resolver, and runs the engine. The returned result is the single source of truth; callers serialize it as their transport requires.
Types ¶
type Option ¶
type Option func(*Options)
Option mutates Options.
func WithContext ¶
WithContext propagates a request-scoped context to every node execution (cancellation + deadlines). Defaults to context.Background().
func WithDynamicVars ¶
func WithDynamicVars(d spi.DynamicResolver) Option
WithDynamicVars enables {{$name}} dynamic variable resolution.
func WithMiddleware ¶
func WithMiddleware(middleware ...engine.Middleware) Option
WithMiddleware wraps each node's execution (outermost first). Use the Retry / Timeout helpers or any custom engine.Middleware.
func WithModuleCallStack ¶
WithModuleCallStack seeds the module-cycle-detection call stack (for nested module execution).
func WithObserver ¶
func WithObserver(obs engine.ExecutionObserver) Option
WithObserver streams progress/terminal events to obs (SSE+DB for cloud, job events for self-hosted, none for ephemeral).
func WithReferencedFlows ¶
func WithReferencedFlows(refs flow.ReferencedFlowRegistry) Option
WithReferencedFlows supplies the child flow definitions module nodes execute without calling back to the control plane.
type Options ¶
type Options struct {
Observer engine.ExecutionObserver
ReferencedFlows flow.ReferencedFlowRegistry
DynamicVars spi.DynamicResolver
ModuleCallStack []string
Ctx context.Context
Middleware []engine.Middleware
}
Options configures a Run. Use the With* helpers; the zero value runs with a no-op observer, no referenced flows, and no dynamic variables.