#[non_exhaustive]pub struct WorkflowDef { /* private fields */ }Expand description
A workflow definition: a condition and a tree of steps.
Only parse makes one, and nothing changes one after:
every field is read through its accessor, so a definition a compiler sees
has passed every rule parse checks, and the interpreter can trust them.
use dataflow_rs::def::{ParseOptions, StepDef, parse};
use serde_json::json;
let json = json!({"id": "w", "priority": 5, "tasks": [
{"id": "t", "function": {"name": "log", "input": {"message": "hi"}}}
]});
let def = parse(&json, ParseOptions::default()).def.unwrap();
assert_eq!((def.id(), def.priority()), ("w", 5));
let StepDef::Task(task) = &def.tasks()[0] else { unreachable!() };
assert_eq!(task.function().name(), "log");A field cannot be assigned:
let json = json!({"id": "w", "tasks": []});
let mut def = parse(&json, ParseOptions::default()).def.unwrap();
def.priority = 5;Implementations§
Source§impl WorkflowDef
impl WorkflowDef
Sourcepub fn header(&self) -> &NodeHeader
pub fn header(&self) -> &NodeHeader
The name, description and ext.
Sourcepub fn priority(&self) -> u32
pub fn priority(&self) -> u32
The run order: lower runs first, and equal priorities keep their order. Default 0.
Sourcepub fn condition(&self) -> Option<&Logic>
pub fn condition(&self) -> Option<&Logic>
Whether a message enters the workflow. Absent means true.
Sourcepub fn on_failure(&self) -> WorkflowFailurePolicy
pub fn on_failure(&self) -> WorkflowFailurePolicy
What a task’s failure that reaches the workflow does. Default fail.
Sourcepub fn rollout(&self) -> Option<&Rollout>
pub fn rollout(&self) -> Option<&Rollout>
The workflow’s slice of the traffic on its channel. None runs for
every message.
Tags for the host’s filtering.
Sourcepub fn created_at(&self) -> Option<DateTime<Utc>>
pub fn created_at(&self) -> Option<DateTime<Utc>>
When the definition was created. Kept for stored definitions, never read.
Sourcepub fn updated_at(&self) -> Option<DateTime<Utc>>
pub fn updated_at(&self) -> Option<DateTime<Utc>>
When the definition was last updated. Kept, never read.
Sourcepub fn walk(&self) -> impl Iterator<Item = (AuthoredPath, StepKind, &StepDef)>
pub fn walk(&self) -> impl Iterator<Item = (AuthoredPath, StepKind, &StepDef)>
Every step with its authored path and kind, pre-order: loop.setup
first, then tasks, each group before its members.
A task’s kind is StepKind::Task and a group’s StepKind::Group;
every step under loop.setup, group or task, is StepKind::Setup.