Skip to main content

Executor

Trait Executor 

Source
pub trait Executor: Send + Sync {
    // Required methods
    fn id(&self) -> &str;
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        message: Value,
        ctx: WorkflowContext,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn snapshot_state<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Option<Value>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn restore_state<'life0, 'async_trait>(
        &'life0 self,
        _state: Value,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

A node in a workflow graph.

Rust equivalent of the Python Executor. Each executor receives a message (as a JSON value) and a WorkflowContext handle through which it sends messages, yields outputs, and emits events.

Required Methods§

Source

fn id(&self) -> &str

A unique id for this executor within the workflow.

Source

fn execute<'life0, 'async_trait>( &'life0 self, message: Value, ctx: WorkflowContext, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Handle an incoming message.

Provided Methods§

Source

fn snapshot_state<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<Value>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Capture serializable state for checkpointing.

Stateful executors override this to return a JSON snapshot that is stored in the checkpoint and handed back to Executor::restore_state on resume. Returning None (the default) means the executor is stateless.

Source

fn restore_state<'life0, 'async_trait>( &'life0 self, _state: Value, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Restore state previously produced by Executor::snapshot_state.

The default implementation ignores the state. Only executors that snapshot state need to implement this.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§