pub struct WorkflowEngine { /* private fields */ }Expand description
Central coordinator for workflow execution
Manages workflow lifecycle (create, start, pause, resume, cancel) and tracks active workflows. Handles step execution orchestration and dependency resolution.
Implementations§
Source§impl WorkflowEngine
impl WorkflowEngine
Sourcepub fn create_execution(
&mut self,
workflow: &Workflow,
) -> WorkflowResult<String>
pub fn create_execution( &mut self, workflow: &Workflow, ) -> WorkflowResult<String>
Create a new workflow execution
Creates a new execution state for the given workflow and tracks it.
Sourcepub fn start_execution(&mut self, execution_id: &str) -> WorkflowResult<()>
pub fn start_execution(&mut self, execution_id: &str) -> WorkflowResult<()>
Start workflow execution
Transitions the workflow from pending to running state.
Sourcepub fn pause_execution(&mut self, execution_id: &str) -> WorkflowResult<()>
pub fn pause_execution(&mut self, execution_id: &str) -> WorkflowResult<()>
Pause workflow execution
Pauses the workflow at the current step, allowing resumption later.
Sourcepub fn resume_execution(&mut self, execution_id: &str) -> WorkflowResult<()>
pub fn resume_execution(&mut self, execution_id: &str) -> WorkflowResult<()>
Resume workflow execution
Resumes a paused workflow from the last completed step.
Sourcepub fn cancel_execution(&mut self, execution_id: &str) -> WorkflowResult<()>
pub fn cancel_execution(&mut self, execution_id: &str) -> WorkflowResult<()>
Cancel workflow execution
Cancels the workflow, stopping any further execution.
Sourcepub fn get_execution_state(
&self,
execution_id: &str,
) -> WorkflowResult<WorkflowState>
pub fn get_execution_state( &self, execution_id: &str, ) -> WorkflowResult<WorkflowState>
Get the current state of a workflow execution
Sourcepub fn get_execution_order(workflow: &Workflow) -> WorkflowResult<Vec<String>>
pub fn get_execution_order(workflow: &Workflow) -> WorkflowResult<Vec<String>>
Get execution order for workflow steps
Builds execution order from dependency graph using topological sort. Returns error if circular dependencies are detected.
Sourcepub fn can_execute_step(
workflow: &Workflow,
state: &WorkflowState,
step_id: &str,
) -> WorkflowResult<bool>
pub fn can_execute_step( workflow: &Workflow, state: &WorkflowState, step_id: &str, ) -> WorkflowResult<bool>
Check if a step can be executed
A step can be executed if all its dependencies have been completed.
Sourcepub fn get_next_step(
workflow: &Workflow,
state: &WorkflowState,
) -> WorkflowResult<Option<String>>
pub fn get_next_step( workflow: &Workflow, state: &WorkflowState, ) -> WorkflowResult<Option<String>>
Get next executable step
Returns the next step that can be executed based on completed dependencies. Returns None if all steps are completed or no steps are ready.
Sourcepub fn wait_for_dependencies(
workflow: &Workflow,
state: &WorkflowState,
step_id: &str,
) -> WorkflowResult<()>
pub fn wait_for_dependencies( workflow: &Workflow, state: &WorkflowState, step_id: &str, ) -> WorkflowResult<()>
Wait for a step’s dependencies to complete
Blocks until all dependencies for the given step are completed. Returns error if the step is not found or dependencies cannot be resolved.
Sourcepub fn complete_execution(&mut self, execution_id: &str) -> WorkflowResult<()>
pub fn complete_execution(&mut self, execution_id: &str) -> WorkflowResult<()>
Complete workflow execution
Sourcepub fn fail_execution(&mut self, execution_id: &str) -> WorkflowResult<()>
pub fn fail_execution(&mut self, execution_id: &str) -> WorkflowResult<()>
Fail workflow execution
Sourcepub fn remove_execution(
&mut self,
execution_id: &str,
) -> WorkflowResult<WorkflowState>
pub fn remove_execution( &mut self, execution_id: &str, ) -> WorkflowResult<WorkflowState>
Remove a completed execution from tracking
Sourcepub fn get_active_executions(&self) -> Vec<String>
pub fn get_active_executions(&self) -> Vec<String>
Get all active executions
Sourcepub fn active_execution_count(&self) -> usize
pub fn active_execution_count(&self) -> usize
Get count of active executions