Skip to main content

Module def

Module def 

Source
Expand description

Definitions: the authored form of workflows and tasks.

A definition is plain data with raw expressions. It enters only through parse or parse_owned, which also lint: one walk over the authored JSON builds a WorkflowDef and reports every issue at the path the author typed, at v3’s codes for v3’s rules. With ParseOptions::compat on, the compat reader rewrites v3’s spellings first (see compat). A definition serializes in the v4 spelling, which parse reads back with the reader off.

use dataflow_rs::def::{ParseOptions, parse};
use dataflow_rs::program::IssueCode;
use serde_json::json;

let parsed = parse(
    &json!({"id": "w", "tasks": [
        {"id": "t", "conditon": true, "function": {"name": "f"}}
    ]}),
    ParseOptions::default(),
);
// A near miss of a known key loads, kept in the task's `ext`, and is reported.
assert_eq!(parsed.issues[0].code, IssueCode::LikelyTypo);
assert_eq!(parsed.issues[0].path.to_string(), "tasks[0].conditon");
assert!(parsed.def.is_some());

Modules§

defaults
The value parse reads for an absent key, which Serialize leaves out. A tool that shows a definition reads them here rather than keeping its own copy.

Structs§

DefinitionKeys
The known keys at each level of a definition, as the reader, the walk and the serializer read them. A tool that shows definitions — the debugger reads it through the wasm package — holds its own view to these rather than keeping a copy that drifts when a key is added.
ForEachDef
A task’s fan-out: its function runs once per element of an array.
FunctionRef
The function a task runs.
GroupDef
A group: a span of steps sharing one condition, evaluated once on entry.
Logic
Raw JSONLogic as authored. Only a compiler turns it into an Expr.
LoopDef
A workflow’s bounded loop: the task list runs once per sweep while counter < max.
NodeHeader
The keys every node shares: a workflow, a task and a group. name is optional everywhere, which relaxes v3.
ParseOptions
How parse reads a definition.
Parsed
What parse found.
Rollout
Half-open bucket range [bucket_start, bucket_end) over 0..100, giving this workflow a slice of the traffic on its channel.
TaskDef
A task: one function call, with its outcome policies.
WorkflowDef
A workflow definition: a condition and a tree of steps.

Enums§

FailurePolicy
What a task’s failure (a 5xx or an Err) does.
RejectionPolicy
What a task’s rejection (a 4xx) does.
RolloutError
Why a rollout set is not a valid traffic split.
Status
A workflow’s lifecycle status.
StepDef
One element of a step list. An element carrying a tasks key is a group.
WorkflowFailurePolicy
What a failure that reaches the workflow does.

Constants§

BUILTIN_FUNCTIONS
The built-in function names. They are reserved: no registration shadows one, and a task running one cannot carry for_each, since a built-in runs inline.
MAX_GROUP_DEPTH
The deepest group nesting a definition may use.

Functions§

definition_keys
The known keys at each level of a definition.
is_reserved_function
Whether no host function may be registered as name: a name in BUILTIN_FUNCTIONS, since a built-in cannot be shadowed, or validate, 3.x’s alias for validation, which the compat reader rewrites before any name is looked up. Registry::register panics on one; a host that registers names from data checks them here first.
parse
Reads one authored workflow definition. Never fails: every problem is an issue, and the definition is built exactly when none is Rejected.
parse_owned
Reads a definition by value. The compatibility reader rewrites the owned JSON in place, avoiding the full-document copy required by parse. The resulting definition and issue ordering are identical to parse.