pub struct WorkflowBuilder { /* private fields */ }Expand description
Fluent builder for a Workflow. Rust equivalent of WorkflowBuilder.
Implementations§
Source§impl WorkflowBuilder
impl WorkflowBuilder
Sourcepub fn new() -> WorkflowBuilder
pub fn new() -> WorkflowBuilder
Create a new, empty builder.
Sourcepub fn add_executor(self, executor: Arc<dyn Executor>) -> WorkflowBuilder
pub fn add_executor(self, executor: Arc<dyn Executor>) -> WorkflowBuilder
Register an executor. Executors are keyed by their Executor::id.
Sourcepub fn set_start(self, id: impl Into<String>) -> WorkflowBuilder
pub fn set_start(self, id: impl Into<String>) -> WorkflowBuilder
Set the entry-point executor (by id). The initial message is delivered here.
Sourcepub fn add_edge(
self,
source: impl Into<String>,
target: impl Into<String>,
) -> WorkflowBuilder
pub fn add_edge( self, source: impl Into<String>, target: impl Into<String>, ) -> WorkflowBuilder
Add a single directed edge.
Sourcepub fn add_conditional_edge(
self,
source: impl Into<String>,
target: impl Into<String>,
condition: impl Fn(&Value) -> bool + Send + Sync + 'static,
) -> WorkflowBuilder
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.
Sourcepub fn add_conditional_edge_async<F, Fut>(
self,
source: impl Into<String>,
target: impl Into<String>,
condition: F,
) -> WorkflowBuilder
pub fn add_conditional_edge_async<F, Fut>( self, source: impl Into<String>, target: impl Into<String>, condition: F, ) -> WorkflowBuilder
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).
Sourcepub fn add_fan_out(
self,
source: impl Into<String>,
targets: impl IntoIterator<Item = String>,
) -> WorkflowBuilder
pub fn add_fan_out( self, source: impl Into<String>, targets: impl IntoIterator<Item = String>, ) -> WorkflowBuilder
Broadcast from source to all targets.
Sourcepub fn add_fan_in(
self,
sources: impl IntoIterator<Item = String>,
target: impl Into<String>,
) -> WorkflowBuilder
pub fn add_fan_in( self, sources: impl IntoIterator<Item = String>, target: impl Into<String>, ) -> WorkflowBuilder
Fan in from sources to target (barrier).
Sourcepub fn add_switch(
self,
source: impl Into<String>,
cases: Vec<Case>,
default: Default,
) -> WorkflowBuilder
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.
Sourcepub fn add_chain(self, ids: impl IntoIterator<Item = String>) -> WorkflowBuilder
pub fn add_chain(self, ids: impl IntoIterator<Item = String>) -> WorkflowBuilder
Chain executors sequentially (sugar for consecutive edges).
Sourcepub fn set_max_iterations(self, n: usize) -> WorkflowBuilder
pub fn set_max_iterations(self, n: usize) -> WorkflowBuilder
Set the maximum number of supersteps before the run fails.
Sourcepub fn name(self, name: impl Into<String>) -> WorkflowBuilder
pub fn name(self, name: impl Into<String>) -> WorkflowBuilder
Set the workflow name.
Sourcepub fn description(self, description: impl Into<String>) -> WorkflowBuilder
pub fn description(self, description: impl Into<String>) -> WorkflowBuilder
Set the workflow description.
Sourcepub fn with_checkpointing(
self,
storage: Arc<dyn CheckpointStorage>,
) -> WorkflowBuilder
pub fn with_checkpointing( self, storage: Arc<dyn CheckpointStorage>, ) -> WorkflowBuilder
Enable automatic checkpointing to storage at each superstep boundary.
Sourcepub fn output_from(
self,
ids: impl IntoIterator<Item = impl Into<String>>,
) -> WorkflowBuilder
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.
Sourcepub fn intermediate_output_from(
self,
ids: impl IntoIterator<Item = impl Into<String>>,
) -> WorkflowBuilder
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.