Skip to main content

WorkflowExecutor

Trait WorkflowExecutor 

Source
pub trait WorkflowExecutor<W: WorkflowDefinition>: Send + Sync {
    // Required methods
    fn load<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        account: &'life1 AccountId,
        case_id: &'life2 CaseId,
    ) -> Pin<Box<dyn Future<Output = Result<Versioned<Option<W::State>>, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        batch: CommandBatch<W::Command>,
    ) -> Pin<Box<dyn Future<Output = Result<Commit<W::State, W::Event>, ExecutionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Loads and mutates cases of one workflow (spec §8.2).

Required Methods§

Source

fn load<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, account: &'life1 AccountId, case_id: &'life2 CaseId, ) -> Pin<Box<dyn Future<Output = Result<Versioned<Option<W::State>>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Loads a case for an account. None value means the case does not exist; its revision is then crate::ids::CaseRevision::ZERO. An executor must never delete a case to express completion, because a completed case keeps its row and moves to a terminal status, so an absent state always means the case has not been created yet.

Source

fn execute<'life0, 'async_trait>( &'life0 self, batch: CommandBatch<W::Command>, ) -> Pin<Box<dyn Future<Output = Result<Commit<W::State, W::Event>, ExecutionError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Executes a batch under its atomicity scope with revision and idempotency checks (I13, I14).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<W, E> WorkflowExecutor<W> for Arc<E>

A shared executor is an executor.

WorkflowRegistryBuilder::register takes the executor by value, so an application that also holds its own handle on it — to seed a case, to read a revision back, to share one connection pool between two workflows — would otherwise have to wrap the Arc in a newtype just to re-implement two forwarding methods. This impl is that newtype, written once.

Source§

fn load<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, account: &'life1 AccountId, case_id: &'life2 CaseId, ) -> Pin<Box<dyn Future<Output = Result<Versioned<Option<W::State>>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

fn execute<'life0, 'async_trait>( &'life0 self, batch: CommandBatch<W::Command>, ) -> Pin<Box<dyn Future<Output = Result<Commit<W::State, W::Event>, ExecutionError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§