pub struct WorkflowContext { /* private fields */ }Expand description
Collects the effects an executor produces while handling a message:
messages to send downstream, workflow outputs, custom events, info
requests, and access to run-scoped SharedState.
This is a cheap, cloneable handle (interior mutability) so executor
closures may own it and hold it across await points. Rust equivalent of
WorkflowContext.
Implementations§
Source§impl WorkflowContext
impl WorkflowContext
Sourcepub async fn send_message(&self, data: impl Into<Value>) -> Result<(), Error>
pub async fn send_message(&self, data: impl Into<Value>) -> Result<(), Error>
Send a message to all connected downstream executors.
Sourcepub async fn send_to(
&self,
target_id: impl Into<String>,
data: impl Into<Value>,
) -> Result<(), Error>
pub async fn send_to( &self, target_id: impl Into<String>, data: impl Into<Value>, ) -> Result<(), Error>
Send a message to a specific downstream executor.
Sourcepub async fn yield_output(&self, data: impl Into<Value>) -> Result<(), Error>
pub async fn yield_output(&self, data: impl Into<Value>) -> Result<(), Error>
Emit a workflow-level output.
Sourcepub fn add_event(&self, event: WorkflowEvent)
pub fn add_event(&self, event: WorkflowEvent)
Add a custom event to the event stream.
Sourcepub async fn request_info(&self, data: impl Into<Value>) -> Result<(), Error>
pub async fn request_info(&self, data: impl Into<Value>) -> Result<(), Error>
Request external information (human-in-the-loop).
Records a request whose response, once supplied via the run handle, is
delivered back to this executor as a message. Mirrors Python’s
ctx.request_info.
Access the run-scoped SharedState shared by all executors.
Sourcepub fn executor_id(&self) -> &str
pub fn executor_id(&self) -> &str
The id of the executor this context belongs to.
Sourcepub fn source_executor_ids(&self) -> &[String]
pub fn source_executor_ids(&self) -> &[String]
The id(s) of the executor(s) that sent the current message.
Trait Implementations§
Source§impl Clone for WorkflowContext
impl Clone for WorkflowContext
Source§fn clone(&self) -> WorkflowContext
fn clone(&self) -> WorkflowContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more