Skip to main content

WorkflowDef

Struct WorkflowDef 

Source
#[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

Source

pub fn id(&self) -> &str

The workflow’s id: a non-empty string.

Source

pub fn header(&self) -> &NodeHeader

The name, description and ext.

Source

pub fn priority(&self) -> u32

The run order: lower runs first, and equal priorities keep their order. Default 0.

Source

pub fn condition(&self) -> Option<&Logic>

Whether a message enters the workflow. Absent means true.

Source

pub fn tasks(&self) -> &[StepDef]

The steps, as authored: tasks and groups.

Source

pub fn on_failure(&self) -> WorkflowFailurePolicy

What a task’s failure that reaches the workflow does. Default fail.

Source

pub fn channel(&self) -> &str

The routing channel. Default "default", as in v3.

Source

pub fn status(&self) -> Status

The lifecycle status. Default active.

Source

pub fn version(&self) -> u32

The definition’s version. Default 1.

Source

pub fn rollout(&self) -> Option<&Rollout>

The workflow’s slice of the traffic on its channel. None runs for every message.

Source

pub fn loop(&self) -> Option<&LoopDef>

The bounded loop over the task list, if any.

Source

pub fn tags(&self) -> &[String]

Tags for the host’s filtering.

Source

pub fn created_at(&self) -> Option<DateTime<Utc>>

When the definition was created. Kept for stored definitions, never read.

Source

pub fn updated_at(&self) -> Option<DateTime<Utc>>

When the definition was last updated. Kept, never read.

Source

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.

Trait Implementations§

Source§

impl Clone for WorkflowDef

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WorkflowDef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for WorkflowDef

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for WorkflowDef

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for WorkflowDef

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.