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 { ... }
fn reset<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn describe_protocol(&self) -> ProtocolDescriptor { ... }
fn request_port(&self) -> Option<RequestPortInfo> { ... }
}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§
Provided Methods§
Sourcefn 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 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.
Sourcefn 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,
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.
Sourcefn reset<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn reset<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Reset per-run state before a fresh run (upstream IResettableExecutor):
an executor instance is shared by every run of its workflow, so one
that keeps per-run state clears it here. Called on every executor at
the start of a run (not on a resume from a checkpoint). The default
does nothing.
Sourcefn describe_protocol(&self) -> ProtocolDescriptor
fn describe_protocol(&self) -> ProtocolDescriptor
The message types this executor accepts, sends and yields (upstream
DescribeProtocol). Payloads here are JSON, so types are names the
workflow’s author chooses (or JSON type names). The default accepts
anything and declares nothing.
Sourcefn request_port(&self) -> Option<RequestPortInfo>
fn request_port(&self) -> Option<RequestPortInfo>
For a request port (a node that hands requests to the caller), its
request and response type names; None for other executors.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".