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
parsereads for an absent key, whichSerializeleaves out. A tool that shows a definition reads them here rather than keeping its own copy.
Structs§
- Definition
Keys - 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.
- ForEach
Def - A task’s fan-out: its function runs once per element of an array.
- Function
Ref - The function a task runs.
- Group
Def - 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. - Node
Header - The keys every node shares: a workflow, a task and a group.
nameis optional everywhere, which relaxes v3. - Parse
Options - How
parsereads a definition. - Parsed
- What
parsefound. - Rollout
- Half-open bucket range
[bucket_start, bucket_end)over0..100, giving this workflow a slice of the traffic on its channel. - TaskDef
- A task: one function call, with its outcome policies.
- Workflow
Def - A workflow definition: a condition and a tree of steps.
Enums§
- Failure
Policy - What a task’s failure (a 5xx or an
Err) does. - Rejection
Policy - What a task’s rejection (a 4xx) does.
- Rollout
Error - 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
taskskey is a group. - Workflow
Failure Policy - 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 inBUILTIN_FUNCTIONS, since a built-in cannot be shadowed, orvalidate, 3.x’s alias forvalidation, which the compat reader rewrites before any name is looked up.Registry::registerpanics 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 toparse.