Skip to main content

OrchestrationContext

Struct OrchestrationContext 

Source
pub struct OrchestrationContext { /* private fields */ }
Expand description

The orchestration context provided to orchestrator functions.

All methods are safe to call from async code. The context is cloneable and thread-safe (Send + Sync), backed by Arc<Mutex<>>.

Implementations§

Source§

impl OrchestrationContext

Source

pub fn instance_id(&self) -> String

Get the instance ID.

Source

pub fn current_utc_datetime(&self) -> DateTime<Utc>

Get the current UTC datetime (deterministic, from history events).

Source

pub fn is_replaying(&self) -> bool

Check if the orchestrator is currently replaying.

Source

pub fn name(&self) -> String

Get the orchestration name.

Source

pub fn get_input<T: DeserializeOwned>(&self) -> Result<T>

Get the orchestration input, deserialised from JSON.

Source

pub fn propagated_history(&self) -> Option<PropagatedHistory>

Returns history forwarded from the parent workflow, if the parent scheduled this child with a non-None history propagation scope.

See HistoryPropagationScope for the parent-side trade-off between OwnHistory and Lineage.

Source

pub fn set_custom_status(&self, status: impl Into<String>)

Set a custom status string.

Source

pub fn call_activity( &self, name: &str, input: impl Serialize, ) -> CompletableTask

Schedule an activity for execution.

Returns a CompletableTask that resolves when the activity completes.

During replay: if the corresponding TaskCompleted/TaskFailed event exists in history, the task will already be complete. During new execution: creates a ScheduleTaskAction.

Source

pub fn call_activity_with_app_id( &self, name: &str, input: impl Serialize, app_id: &str, ) -> CompletableTask

Schedule an activity with an app_id for cross-app scenarios.

Source

pub fn call_activity_with_options( &self, name: &str, input: impl Serialize, options: ActivityOptions, ) -> BoxFuture<'static, Result<Option<String>>>

Schedule an activity with options (retry policy, app ID).

Returns a future that drives the activity to completion, transparently scheduling durable timers and re-issuing the activity on each retry.

Source

pub fn call_sub_orchestrator( &self, name: &str, input: impl Serialize, instance_id: Option<&str>, ) -> CompletableTask

Schedule a sub-orchestration for execution.

Source

pub fn call_sub_orchestrator_with_app_id( &self, name: &str, input: impl Serialize, instance_id: Option<&str>, app_id: &str, ) -> CompletableTask

Schedule a sub-orchestration targeting a specific Dapr app ID.

Source

pub fn call_sub_orchestrator_with_options( &self, name: &str, input: impl Serialize, options: SubOrchestratorOptions, ) -> BoxFuture<'static, Result<Option<String>>>

Schedule a sub-orchestration with options (instance ID, retry policy, app ID).

Returns a future that drives the sub-orchestration to completion, transparently scheduling durable timers and re-issuing the call on each retry.

Note: when a retry policy is set and no explicit instance_id is given, each retry uses a freshly generated instance ID.

Source

pub fn create_timer(&self, delay: Duration) -> CompletableTask

Create a durable timer that fires after the specified duration.

Source

pub fn wait_for_external_event(&self, name: &str) -> CompletableTask

Wait for an external event with the given name.

Event names are case-insensitive.

Source

pub fn continue_as_new(&self, input: impl Serialize, save_events: bool)

Continue the orchestration as new with new input.

Source

pub fn is_patched(&self, patch_name: &str) -> bool

Check whether a named patch should be applied in the current execution.

This enables safe, deterministic code upgrades. Wrap new behaviour in if ctx.is_patched("my-patch") to ensure that:

  • Replaying executions that previously ran the unpatched path continue on the unpatched path (preserving determinism).
  • Executions that previously ran the patched path continue on the patched path.
  • Brand-new executions (at the history frontier) always take the patched path.

This matches the behaviour of the Go and Python SDKs.

Trait Implementations§

Source§

impl Clone for OrchestrationContext

Source§

fn clone(&self) -> OrchestrationContext

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more

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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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