WorkflowEngine

Struct WorkflowEngine 

Source
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

Source

pub fn new() -> Self

Create a new workflow engine

Source

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.

Source

pub fn start_execution(&mut self, execution_id: &str) -> WorkflowResult<()>

Start workflow execution

Transitions the workflow from pending to running state.

Source

pub fn pause_execution(&mut self, execution_id: &str) -> WorkflowResult<()>

Pause workflow execution

Pauses the workflow at the current step, allowing resumption later.

Source

pub fn resume_execution(&mut self, execution_id: &str) -> WorkflowResult<()>

Resume workflow execution

Resumes a paused workflow from the last completed step.

Source

pub fn cancel_execution(&mut self, execution_id: &str) -> WorkflowResult<()>

Cancel workflow execution

Cancels the workflow, stopping any further execution.

Source

pub fn get_execution_state( &self, execution_id: &str, ) -> WorkflowResult<WorkflowState>

Get the current state of a workflow execution

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn complete_execution(&mut self, execution_id: &str) -> WorkflowResult<()>

Complete workflow execution

Source

pub fn fail_execution(&mut self, execution_id: &str) -> WorkflowResult<()>

Fail workflow execution

Source

pub fn remove_execution( &mut self, execution_id: &str, ) -> WorkflowResult<WorkflowState>

Remove a completed execution from tracking

Source

pub fn get_active_executions(&self) -> Vec<String>

Get all active executions

Source

pub fn active_execution_count(&self) -> usize

Get count of active executions

Trait Implementations§

Source§

impl Default for WorkflowEngine

Source§

fn default() -> Self

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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.