Skip to content

Feature Request: Add raise_event as a system function in OrchestrationContext #52

@affandar

Description

@affandar

Feature Request

Problem

Currently, to send an external event from one orchestration to another, users need to:

  1. Create a custom activity that wraps client.raise_event()
  2. Register this activity in the activity registry
  3. Schedule the activity from the orchestration

This boilerplate is error-prone and adds unnecessary complexity.

Current Workaround

// send_external_event.rs - Custom activity
pub async fn activity(
    ctx: ActivityContext,
    input: SendExternalEventInput,
) -> Result<SendExternalEventOutput, String> {
    let client = ctx.get_client();
    client
        .raise_event(&input.instance_id, &input.event_name, &input.payload)
        .await
        .map(|_| SendExternalEventOutput { sent: true })
        .map_err(|e| e.to_string())
}

Proposed Solution

Add raise_event as a first-class method on OrchestrationContext:

// In orchestration code
ctx.raise_external_event(
    &target_instance_id,
    "InstanceDeleted",
    &payload
).await?;

This would:

  • Eliminate the need for a custom activity
  • Be consistent with other system operations like schedule_timer
  • Properly integrate with duroxide's event sourcing/replay semantics

Use Case

In Toygres, when deleting an instance, we need to signal the instance's health monitoring actor to gracefully shut down before cleaning up K8s resources:

// delete_instance.rs orchestration
// Signal the actor to stop health checks and exit
ctx.raise_external_event(
    &instance_actor_orchestration_id,
    "InstanceDeleted",
    "{}"
).await;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions