Sending Events & Signals
Workflow-to-Workflow Signals
Workflows coordinate by forwarding events to other workflows. In Python, a workflow can send an event to a child via child_handle.send_event() (Rust exposes the same on its child handle). In all languages, external systems and API handlers send events through the client-side workflow handle's send_event() / sendEvent(). This enables coordination patterns where a parent workflow controls child execution, or sibling workflows notify each other of progress.
Note: In the TypeScript SDK, child-handle event forwarding (
childHandle.sendEvent(...)) is not yet implemented. Forward events to children via the client handle instead, or use Rust/Python for in-workflow child signaling.
1use orcher::prelude::*;2use anyhow::Result;3use std::time::Duration;45#[task]6pub async fn expedited_fulfillment(_ctx: TaskContext, order_id: String) -> Result<()> { /* ... */ }78#[task]9pub async fn standard_fulfillment(_ctx: TaskContext, order_id: String) -> Result<()> { /* ... */ }1011// Child workflow that can be expedited via event12#[workflow]13pub async fn fulfillment_workflow(14 ctx: WorkflowContext,15 order_id: String,16) -> Result<FulfillmentResult> {17 // Check for expedite event (5 minute window)18 let expedite: Option<bool> = ctx19 .wait_for_event_with_timeout("expedite", Duration::from_secs(300))20 .await?;2122 if expedite.unwrap_or(false) {23 ctx.execute_task(expedited_fulfillment, order_id).await?;24 } else {25 ctx.execute_task(standard_fulfillment, order_id).await?;26 }2728 Ok(FulfillmentResult { completed: true })29}3031// Parent workflow that controls the child32#[workflow]33pub async fn parent_workflow(34 ctx: WorkflowContext,35 order_id: String,36) -> Result<ParentResult> {37 // Start child workflow38 let child_handle = ctx39 .start_child_workflow("fulfillment_workflow", order_id.clone())40 .await?;4142 // Wait for an external expedite request (1 minute window)43 let expedite: Option<bool> = ctx44 .wait_for_event_with_timeout("expedite_request", Duration::from_secs(60))45 .await?;4647 if expedite.unwrap_or(false) {48 // Forward the expedite signal to the child workflow49 child_handle.send_event("expedite", true).await?;50 }5152 // Wait for child to complete53 let result = child_handle.result::<FulfillmentResult>().await?;5455 Ok(ParentResult {56 order_id,57 expedited: expedite.unwrap_or(false),58 child_completed: result.completed,59 })60}Event Buffering
Events are automatically buffered if they arrive before the workflow calls wait_for_event(). This means the order of "send" and "wait" doesn't matter — the event is never lost. On replay, buffered events are replayed from the journal.