pub struct WorkflowExecutor { /* private fields */ }Expand description
Handles the execution of workflows and their tasks
The WorkflowExecutor is responsible for:
- Evaluating workflow conditions
- Orchestrating task execution within workflows
- Managing workflow-level error handling
- Recording audit trails
Implementations§
Source§impl WorkflowExecutor
impl WorkflowExecutor
Sourcepub fn new(task_executor: Arc<TaskExecutor>, engine: Arc<Engine>) -> Self
pub fn new(task_executor: Arc<TaskExecutor>, engine: Arc<Engine>) -> Self
Create a new WorkflowExecutor
Sourcepub fn with_observer(self, observer: Arc<dyn ExecutionObserver>) -> Self
pub fn with_observer(self, observer: Arc<dyn ExecutionObserver>) -> Self
Attach an observer to an existing executor. Replaces any previous one.
Sourcepub fn observer(&self) -> Option<&Arc<dyn ExecutionObserver>>
pub fn observer(&self) -> Option<&Arc<dyn ExecutionObserver>>
The registered observer, if any.
Used by Engine::with_new_workflows to carry the observer across a hot
reload — without it, metrics would stop silently at the first reload.
Sourcepub fn task_functions(&self) -> Arc<HashMap<String, BoxedFunctionHandler>>
pub fn task_functions(&self) -> Arc<HashMap<String, BoxedFunctionHandler>>
Get a clone of the task_functions Arc for reuse in new engines
Sourcepub async fn execute(
&self,
workflow: &Workflow,
message: &mut Message,
now: DateTime<Utc>,
) -> Result<bool>
pub async fn execute( &self, workflow: &Workflow, message: &mut Message, now: DateTime<Utc>, ) -> Result<bool>
Execute a workflow if its condition is met
This method:
- Evaluates the workflow condition
- Executes tasks sequentially if condition is met
- Handles error recovery based on workflow configuration
- Updates message metadata and audit trail
§Arguments
workflow- The workflow to executemessage- The message being processed
§Returns
Result<bool>- Ok(true) if workflow was executed, Ok(false) if skipped, Err on failure
Sourcepub async fn execute_with_trace(
&self,
workflow: &Workflow,
message: &mut Message,
trace: &mut ExecutionTrace,
now: DateTime<Utc>,
) -> Result<bool>
pub async fn execute_with_trace( &self, workflow: &Workflow, message: &mut Message, trace: &mut ExecutionTrace, now: DateTime<Utc>, ) -> Result<bool>
Execute a workflow with step-by-step tracing
Similar to execute but records execution steps for debugging.
Sourcepub async fn run_all(
&self,
workflows: &[&Workflow],
message: &mut Message,
trace: Option<&mut ExecutionTrace>,
now: DateTime<Utc>,
) -> Result<()>
pub async fn run_all( &self, workflows: &[&Workflow], message: &mut Message, trace: Option<&mut ExecutionTrace>, now: DateTime<Utc>, ) -> Result<()>
Drive a message through workflows in order, grouping maximal runs of
consecutive fully_sync workflows into a single shared-arena scope
(execute_sync_workflow_run) and falling back to the per-workflow
.await path (execute_inner) for any workflow containing an async
task.
A thin &[&Workflow] wrapper over Self::run_all_borrowed, which is
the actual shared entry all four Engine::process_message* variants
call directly (against &[Workflow] from the engine’s own registry,
with no per-message Vec<&Workflow> collect). This method exists for
a caller that already holds borrowed references.