Skip to main content

WorkItem

Enum WorkItem 

Source
pub enum WorkItem {
    StartOrchestration {
        instance: String,
        orchestration: String,
        input: String,
        version: Option<String>,
        parent_instance: Option<String>,
        parent_id: Option<u64>,
        execution_id: u64,
    },
    ActivityExecute {
        instance: String,
        execution_id: u64,
        id: u64,
        name: String,
        input: String,
        session_id: Option<String>,
        tag: Option<String>,
    },
    ActivityCompleted {
        instance: String,
        execution_id: u64,
        id: u64,
        result: String,
    },
    ActivityFailed {
        instance: String,
        execution_id: u64,
        id: u64,
        details: ErrorDetails,
    },
    TimerFired {
        instance: String,
        execution_id: u64,
        id: u64,
        fire_at_ms: u64,
    },
    ExternalRaised {
        instance: String,
        name: String,
        data: String,
    },
    SubOrchCompleted {
        parent_instance: String,
        parent_execution_id: u64,
        parent_id: u64,
        result: String,
    },
    SubOrchFailed {
        parent_instance: String,
        parent_execution_id: u64,
        parent_id: u64,
        details: ErrorDetails,
    },
    CancelInstance {
        instance: String,
        reason: String,
    },
    ContinueAsNew {
        instance: String,
        orchestration: String,
        input: String,
        version: Option<String>,
        carry_forward_events: Vec<(String, String)>,
        initial_custom_status: Option<String>,
    },
    QueueMessage {
        instance: String,
        name: String,
        data: String,
    },
}
Expand description

Provider-backed work queue items the runtime consumes continually.

WorkItems represent messages that flow through provider-managed queues. They are serialized/deserialized using serde_json for storage.

§Queue Routing

Different WorkItem types go to different queues:

  • StartOrchestration, ContinueAsNew, ActivityCompleted/Failed, TimerFired, ExternalRaised, SubOrchCompleted/Failed, CancelInstanceOrchestrator queue
    • TimerFired items use visible_at = fire_at_ms for delayed visibility
  • ActivityExecuteWorker queue

§Instance ID Extraction

Most WorkItems have an instance field. Sub-orchestration completions use parent_instance. Providers need to extract the instance ID for routing. SQLite example:

let instance = match &item {
    WorkItem::StartOrchestration { instance, .. } |
    WorkItem::ActivityCompleted { instance, .. } |
    WorkItem::CancelInstance { instance, .. } => instance,
    WorkItem::SubOrchCompleted { parent_instance, .. } => parent_instance,
    _ => return Err("unexpected item type"),
};

§Execution ID Tracking

WorkItems for activities, timers, and sub-orchestrations include execution_id. This allows providers to route completions to the correct execution when ContinueAsNew creates multiple executions.

Critical: Completions with mismatched execution_id should still be enqueued (the runtime filters them).

Variants§

§

StartOrchestration

Start a new orchestration instance

  • Instance metadata is created by runtime via ack_orchestration_item metadata (not on enqueue)
  • execution_id: The execution ID for this start (usually INITIAL_EXECUTION_ID=1)
  • version: None means runtime will resolve from registry

Fields

§instance: String
§orchestration: String
§input: String
§version: Option<String>
§parent_instance: Option<String>
§parent_id: Option<u64>
§execution_id: u64
§

ActivityExecute

Execute an activity (goes to worker queue)

  • id: event_id from ActivityScheduled (for correlation)
  • Worker will enqueue ActivityCompleted or ActivityFailed

Fields

§instance: String
§execution_id: u64
§id: u64
§name: String
§input: String
§session_id: Option<String>
§tag: Option<String>

Routing tag for directing this activity to specific workers. None means default (untagged) queue.

§

ActivityCompleted

Activity completed successfully (goes to orchestrator queue)

  • id: source_event_id referencing the ActivityScheduled event
  • Triggers next orchestration turn

Fields

§instance: String
§execution_id: u64
§id: u64
§result: String
§

ActivityFailed

Activity failed with error (goes to orchestrator queue)

  • id: source_event_id referencing the ActivityScheduled event
  • Triggers next orchestration turn

Fields

§instance: String
§execution_id: u64
§id: u64
§

TimerFired

Timer fired (goes to orchestrator queue with delayed visibility)

  • Created directly by runtime when timer is scheduled
  • Enqueued to orchestrator queue with visible_at = fire_at_ms
  • Orchestrator dispatcher processes when visible_at <= now()

Fields

§instance: String
§execution_id: u64
§id: u64
§fire_at_ms: u64
§

ExternalRaised

External event raised (goes to orchestrator queue)

  • Matched by name to ExternalSubscribed events
  • data: JSON payload from external system

Fields

§instance: String
§name: String
§data: String
§

SubOrchCompleted

Sub-orchestration completed (goes to parent’s orchestrator queue)

  • Routes to parent_instance, not the child
  • parent_id: event_id from parent’s SubOrchestrationScheduled event

Fields

§parent_instance: String
§parent_execution_id: u64
§parent_id: u64
§result: String
§

SubOrchFailed

Sub-orchestration failed (goes to parent’s orchestration queue)

  • Routes to parent_instance, not the child
  • parent_id: event_id from parent’s SubOrchestrationScheduled event

Fields

§parent_instance: String
§parent_execution_id: u64
§parent_id: u64
§

CancelInstance

Request orchestration cancellation (goes to orchestrator queue)

  • Runtime will append OrchestrationCancelRequested event
  • Eventually results in OrchestrationFailed with “canceled: {reason}”

Fields

§instance: String
§reason: String
§

ContinueAsNew

Continue orchestration as new execution (goes to orchestrator queue)

  • Signals the end of current execution and start of next
  • Runtime will create Event::OrchestrationStarted for next execution
  • Provider should create new execution (see ExecutionMetadata.create_next_execution)

Fields

§instance: String
§orchestration: String
§input: String
§version: Option<String>
§carry_forward_events: Vec<(String, String)>

Persistent events carried forward from the previous execution. These are seeded into the new execution’s history before any new externally-raised events, preserving FIFO order across CAN boundaries.

§initial_custom_status: Option<String>

Custom status accumulated from the previous execution, if any. Carried forward so get_custom_status() works immediately in the new execution.

§

QueueMessage

Persistent external event raised (goes to orchestrator queue). Matched by name using FIFO mailbox semantics — events stick around until consumed.

Fields

§instance: String
§name: String
§data: String

Trait Implementations§

Source§

impl Clone for WorkItem

Source§

fn clone(&self) -> WorkItem

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WorkItem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for WorkItem

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for WorkItem

Source§

fn eq(&self, other: &WorkItem) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for WorkItem

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for WorkItem

Source§

impl StructuralPartialEq for WorkItem

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,