nodes

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultRuntime

func DefaultRuntime() node.Runtime

DefaultRuntime wires the production effect implementations. Callers fill Subflow via engine.New and may override Vars.

Types

type AssertCfg

type AssertCfg struct {
	node.Base
}

AssertCfg validates data with no target of its own: its assertions address the input context directly by fully-qualified path — flow inputs by name, any already-executed node's outputs as "nodeID.key". References are checked to exist, so a typo or an unexecuted node is a clear error.

type BranchCase

type BranchCase struct {
	When   assert.Spec `json:"when"`
	Target string      `json:"target"`
}

BranchCase routes to Target when its condition holds over the input context.

type BranchCfg

type BranchCfg struct {
	node.Base

	Cases   []BranchCase `json:"cases"`
	Default string       `json:"default"`
}

BranchCfg routes execution to one successor by the first matching case (or Default). Conditions address the input context directly by fully-qualified path (flow inputs by name, "nodeID.key" for any already-executed node) — no target of its own. A branch never fails on no-match; the engine skips the successors it routes away from (and their subtrees).

func (BranchCfg) RouteTargets

func (c BranchCfg) RouteTargets() []string

RouteTargets implements node.Router: every successor a case or the default may route to, so the engine validates each target has an edge generically.

type DelayCfg

type DelayCfg struct {
	node.Base

	DurationMs int64 `json:"duration_ms"`
}

DelayCfg configures a delay node.

type LoopCfg

type LoopCfg struct {
	node.Base

	Items json.RawMessage `json:"items"`
	// Body is the inline flow run once per item. It is re-templated per iteration
	// with the injected item/index. NOTE: the outer template pass also visits it,
	// so a flow input or node named exactly like a loop variable (item_var /
	// index_var) could be substituted before the loop runs — avoid that collision.
	Body            json.RawMessage `json:"body"`
	ItemVar         string          `json:"item_var"`
	IndexVar        string          `json:"index_var"`
	MaxIterations   int             `json:"max_iterations"`
	ContinueOnError bool            `json:"continue_on_error"`
}

LoopCfg configures a foreach loop: run an inline body flow once per item, injecting the item and its index as inputs, and aggregate each iteration's outputs into a results array. It is a provider node — it exposes the aggregate {results, count} for the engine's assertion/output post-step.

type ModuleCfg

type ModuleCfg struct {
	node.Base

	Body   string    `json:"body_flow_id"`
	Inputs value.Map `json:"inputs"`
}

ModuleCfg configures a module node: run a child flow once with the given inputs. It is the simplest composite node — poll and loop wrap the same RunSubflow/RunInline call in control flow. Inputs decode straight into a value.Map (templates were already resolved by the engine).

func (ModuleCfg) ReferencedFlows

func (c ModuleCfg) ReferencedFlows() []string

ReferencedFlows implements node.FlowReferencer: the child flow this module runs, so the engine validates the reference and detects cycles generically.

type PollCfg

type PollCfg struct {
	node.Base

	// Body is the inline flow polled each attempt (re-templated per attempt with
	// the injected "attempt"). NOTE: the outer template pass also visits it, so a
	// flow input or node named "attempt" could be substituted before polling —
	// avoid that collision.
	Body        json.RawMessage `json:"body"`
	MaxAttempts int             `json:"max_attempts"`
	IntervalMs  int64           `json:"interval_ms"`
	TimeoutMs   int64           `json:"timeout_ms"`
}

PollCfg configures a poll-until node: re-run an inline body flow until the node's assertions (the exit conditions) all pass on a single attempt, or the attempt / deadline budget is exhausted. This is the self-evaluating case — the node calls assert.Run itself per attempt and returns Assert:None so the engine skips its post-step.

type RequestCfg

type RequestCfg struct {
	node.Base

	Method    string            `json:"method"`
	URL       string            `json:"url"`
	Headers   map[string]string `json:"headers,omitempty"`
	Body      string            `json:"body,omitempty"`
	TimeoutMs int64             `json:"timeout_ms,omitempty"`
}

RequestCfg configures an HTTP request node. Its declared assertions and outputs (on the embedded Base) run against the response {status, headers, body} — the node never mentions them.

type SetVariableCfg

type SetVariableCfg struct {
	node.Base

	Variables value.Map `json:"variables"`
}

SetVariableCfg computes named values from templates. The engine resolves the templates before decode, so each variable here is already its final value — decoding boxes them directly (value.Map decodes in one pass). Declared assertions/outputs (on Base) run against the computed map via the engine post-step.

type SseCfg

type SseCfg struct {
	node.Base

	Method                 string            `json:"method"`
	URL                    string            `json:"url"`
	Headers                map[string]string `json:"headers"`
	MaxEvents              int               `json:"max_events"`
	TimeoutMs              int64             `json:"timeout_ms"`
	CompletionEvent        string            `json:"completion_event"`
	StopOnAssertionFailure *bool             `json:"stop_on_assertion_failure"`
}

SseCfg configures a Server-Sent-Events node: connect to a text/event-stream, parse events, and run the node's assertions per event until a stop condition. Self-evaluating (Assert:None) — it owns its per-event assertion cadence.

type WallClock

type WallClock struct{}

WallClock is the production node.Clock: real time, cancellation-aware sleep.

func (WallClock) Now

func (WallClock) Now() time.Time

Now returns the current wall time.

func (WallClock) Sleep

func (WallClock) Sleep(ctx context.Context, d time.Duration) error

Sleep waits for d or until ctx is cancelled, whichever comes first.

Jump to

Keyboard shortcuts

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