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
impl OrchestrationContext
Sourcepub fn instance_id(&self) -> Arc<str> ⓘ
pub fn instance_id(&self) -> Arc<str> ⓘ
Get the instance ID.
Sourcepub fn current_utc_datetime(&self) -> DateTime<Utc>
pub fn current_utc_datetime(&self) -> DateTime<Utc>
Get the current UTC datetime (deterministic, from history events).
Sourcepub fn is_replaying(&self) -> bool
pub fn is_replaying(&self) -> bool
Check if the orchestrator is currently replaying.
Sourcepub fn input<T: DeserializeOwned>(&self) -> Result<T>
pub fn input<T: DeserializeOwned>(&self) -> Result<T>
Get the orchestration input, deserialised from JSON.
Sourcepub fn propagated_history(&self) -> Option<Arc<PropagatedHistory>>
pub fn propagated_history(&self) -> Option<Arc<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.
Sourcepub fn set_custom_status(&self, status: impl Into<String>)
pub fn set_custom_status(&self, status: impl Into<String>)
Set a custom status string.
Sourcepub fn call_activity(
&self,
name: &str,
input: impl Serialize,
) -> CompletableTask ⓘ
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.
Sourcepub fn call_activity_with_app_id(
&self,
name: &str,
input: impl Serialize,
app_id: &str,
) -> CompletableTask ⓘ
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.
Sourcepub fn call_activity_with_options(
&self,
name: &str,
input: impl Serialize,
options: ActivityOptions,
) -> impl Future<Output = Result<Option<String>>> + Send + 'static
pub fn call_activity_with_options( &self, name: &str, input: impl Serialize, options: ActivityOptions, ) -> impl Future<Output = Result<Option<String>>> + Send + 'static
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.
Sourcepub fn call_sub_orchestrator(
&self,
name: &str,
input: impl Serialize,
instance_id: Option<&str>,
) -> CompletableTask ⓘ
pub fn call_sub_orchestrator( &self, name: &str, input: impl Serialize, instance_id: Option<&str>, ) -> CompletableTask ⓘ
Schedule a sub-orchestration for execution.
Sourcepub fn call_sub_orchestrator_with_app_id(
&self,
name: &str,
input: impl Serialize,
instance_id: Option<&str>,
app_id: &str,
) -> CompletableTask ⓘ
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.
Sourcepub fn call_sub_orchestrator_with_options(
&self,
name: &str,
input: impl Serialize,
options: SubOrchestratorOptions,
) -> impl Future<Output = Result<Option<String>>> + Send + 'static
pub fn call_sub_orchestrator_with_options( &self, name: &str, input: impl Serialize, options: SubOrchestratorOptions, ) -> impl Future<Output = Result<Option<String>>> + Send + 'static
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.
Sourcepub fn create_timer(&self, delay: Duration) -> CompletableTask ⓘ
pub fn create_timer(&self, delay: Duration) -> CompletableTask ⓘ
Create a durable timer that fires after the specified duration.
Sourcepub fn wait_for_external_event(&self, name: &str) -> CompletableTask ⓘ
pub fn wait_for_external_event(&self, name: &str) -> CompletableTask ⓘ
Wait for an external event with the given name.
Event names are case-insensitive.
Patched executions also emit a far-future timer tagged with the event name, letting the runtime track the wait.
Sourcepub async fn wait_for_external_event_with_timeout(
&self,
name: &str,
timeout: Duration,
) -> Result<ExternalEventResult>
pub async fn wait_for_external_event_with_timeout( &self, name: &str, timeout: Duration, ) -> Result<ExternalEventResult>
Wait for an external event with a timeout.
Returns ExternalEventResult::Received if the event arrives before
the timeout, or ExternalEventResult::TimedOut if the timeout fires
first.
Always emits a timer tagged with the event name.
Event names are case-insensitive.
Sourcepub fn continue_as_new(&self, input: impl Serialize, save_events: bool)
pub fn continue_as_new(&self, input: impl Serialize, save_events: bool)
Continue the orchestration as new with new input.
Sourcepub fn is_patched(&self, patch_name: &str) -> bool
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
impl Clone for OrchestrationContext
Source§fn clone(&self) -> OrchestrationContext
fn clone(&self) -> OrchestrationContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for OrchestrationContext
impl RefUnwindSafe for OrchestrationContext
impl Send for OrchestrationContext
impl Sync for OrchestrationContext
impl Unpin for OrchestrationContext
impl UnsafeUnpin for OrchestrationContext
impl UnwindSafe for OrchestrationContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request