Skip to main content

WorkflowBuilder

Struct WorkflowBuilder 

Source
pub struct WorkflowBuilder { /* private fields */ }
Expand description

Fluent builder for a Workflow. Rust equivalent of WorkflowBuilder.

Implementations§

Source§

impl WorkflowBuilder

Source

pub fn new() -> WorkflowBuilder

Create a new, empty builder.

Source

pub fn add_executor(self, executor: Arc<dyn Executor>) -> WorkflowBuilder

Register an executor. Executors are keyed by their Executor::id.

Source

pub fn set_start(self, id: impl Into<String>) -> WorkflowBuilder

Set the entry-point executor (by id). The initial message is delivered here.

Source

pub fn add_edge( self, source: impl Into<String>, target: impl Into<String>, ) -> WorkflowBuilder

Add a single directed edge.

Source

pub fn add_conditional_edge( self, source: impl Into<String>, target: impl Into<String>, condition: impl Fn(&Value) -> bool + Send + Sync + 'static, ) -> WorkflowBuilder

Add a single directed edge guarded by a synchronous condition.

Source

pub fn add_conditional_edge_async<F, Fut>( self, source: impl Into<String>, target: impl Into<String>, condition: F, ) -> WorkflowBuilder
where F: Fn(&Value) -> Fut + Send + Sync + 'static, Fut: Future<Output = bool> + Send + 'static,

Add a single directed edge guarded by an async condition.

Equivalent to WorkflowBuilder::add_conditional_edge but for a predicate that itself needs to .await (e.g. an I/O check); the condition is awaited at routing time (see UPSTREAM_DRIFT.md §10, Edge.should_route becoming async upstream).

Source

pub fn add_fan_out( self, source: impl Into<String>, targets: impl IntoIterator<Item = String>, ) -> WorkflowBuilder

Broadcast from source to all targets.

Source

pub fn add_fan_in( self, sources: impl IntoIterator<Item = String>, target: impl Into<String>, ) -> WorkflowBuilder

Fan in from sources to target (barrier).

Source

pub fn add_switch( self, source: impl Into<String>, cases: Vec<Case>, default: Default, ) -> WorkflowBuilder

Add a switch/case group: evaluate cases in order, falling back to default.

Source

pub fn add_chain(self, ids: impl IntoIterator<Item = String>) -> WorkflowBuilder

Chain executors sequentially (sugar for consecutive edges).

Source

pub fn set_max_iterations(self, n: usize) -> WorkflowBuilder

Set the maximum number of supersteps before the run fails.

Source

pub fn name(self, name: impl Into<String>) -> WorkflowBuilder

Set the workflow name.

Source

pub fn description(self, description: impl Into<String>) -> WorkflowBuilder

Set the workflow description.

Source

pub fn with_checkpointing( self, storage: Arc<dyn CheckpointStorage>, ) -> WorkflowBuilder

Enable automatic checkpointing to storage at each superstep boundary.

Source

pub fn output_from( self, ids: impl IntoIterator<Item = impl Into<String>>, ) -> WorkflowBuilder

Designate ids as workflow-level output sources: their yield_output calls become terminal WorkflowEvent::Output events and are recorded in WorkflowRun::last_output/WorkflowRun::outputs.

Once any executor is designated with output_from, executors not named here (and not named via WorkflowBuilder::intermediate_output_from) have their yields demoted to non-terminal WorkflowEvent::Intermediate events rather than dropped — see WorkflowEvent::Intermediate for the full precedence rule. Leaving both designation lists empty preserves the default behavior: every yield is a terminal Output.

Rejected at WorkflowBuilder::build if any id is unknown or overlaps WorkflowBuilder::intermediate_output_from.

Source

pub fn intermediate_output_from( self, ids: impl IntoIterator<Item = impl Into<String>>, ) -> WorkflowBuilder

Designate ids as intermediate-output sources: their yield_output calls become non-terminal WorkflowEvent::Intermediate events and are never recorded as the run’s final output.

Rejected at WorkflowBuilder::build if any id is unknown or overlaps WorkflowBuilder::output_from.

Source

pub fn build(self) -> Result<Workflow, Error>

Validate and build the workflow.

Trait Implementations§

Source§

impl Default for WorkflowBuilder

Source§

fn default() -> WorkflowBuilder

Returns the “default value” for a type. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more