pub struct DurableOrchestrationContext {
pub instance_id: String,
pub parent_instance_id: Option<String>,
pub input: Value,
/* private fields */
}
Expand description
Represents the Durable Functions orchestration context binding.
The following binding attributes are supported:
Name | Description |
---|---|
name | The name of the parameter being bound. |
orchestration | The name of the orchestration. Defaults to the name of the function. |
§Examples
Calling multiple activities and waiting for them all to complete:
use azure_functions::{bindings::DurableOrchestrationContext, durable::OrchestrationOutput, func};
use serde_json::Value;
use log::error;
#[func]
pub async fn run(context: DurableOrchestrationContext) -> OrchestrationOutput {
let activities = vec![
context.call_activity("say_hello", "Tokyo"),
context.call_activity("say_hello", "London"),
context.call_activity("say_hello", "Seattle"),
];
context.set_custom_status("Waiting for all activities to complete.");
let result: Value = context
.join_all(activities)
.await
.into_iter()
.filter_map(|r| {
r.map(Some).unwrap_or_else(|e| {
error!("Activity failed: {}", e);
None
})
})
.collect::<Vec<_>>()
.into();
context.set_custom_status("All activities have completed.");
result.into()
}
Fields§
§instance_id: String
The orchestration instance identifier.
parent_instance_id: Option<String>
The parent orchestration instance identifier.
input: Value
The input value to the orchestration.
Implementations§
Source§impl DurableOrchestrationContext
impl DurableOrchestrationContext
Sourcepub fn is_replaying(&self) -> bool
pub fn is_replaying(&self) -> bool
Gets a value indicating whether the orchestrator function is currently replaying itself.
Sourcepub fn current_time(&self) -> DateTime<Utc>
pub fn current_time(&self) -> DateTime<Utc>
Gets the current date/time in a way that is safe for use by orchestrator functions.
Sourcepub fn set_custom_status<S>(&self, status: S)
pub fn set_custom_status<S>(&self, status: S)
Sets the custom status of the orchestration.
Sourcepub fn new_guid(&self) -> Uuid
pub fn new_guid(&self) -> Uuid
Create a new deterministic GUID suitable for use with orchestrations.
Sourcepub fn join_all<I>(&self, iter: I) -> JoinAll<I::Item> ⓘ
pub fn join_all<I>(&self, iter: I) -> JoinAll<I::Item> ⓘ
Creates a future which represents a collection of the outputs of the futures given.
The returned future will drive execution for all of its underlying futures,
collecting the results into a destination Vec<T>
in the same order as they
were provided.
Sourcepub fn select_all<I>(&self, iter: I) -> SelectAll<I::Item> ⓘ
pub fn select_all<I>(&self, iter: I) -> SelectAll<I::Item> ⓘ
Creates a new future which will select over a list of futures.
The returned future will wait for any future within iter
to be ready. Upon
completion the item resolved will be returned, along with the index of the
future that was ready and the list of all the remaining futures.
§Panics
This function will panic if the iterator specified contains no items.
Sourcepub fn call_activity<D>(
&self,
activity_name: &str,
data: D,
) -> ActionFuture<Result<Value, String>> ⓘ
pub fn call_activity<D>( &self, activity_name: &str, data: D, ) -> ActionFuture<Result<Value, String>> ⓘ
Schedules an activity function for execution.
Sourcepub fn call_activity_with_retry<D>(
&self,
activity_name: &str,
data: D,
retry_options: RetryOptions,
) -> ActionFuture<Result<Value, String>> ⓘ
pub fn call_activity_with_retry<D>( &self, activity_name: &str, data: D, retry_options: RetryOptions, ) -> ActionFuture<Result<Value, String>> ⓘ
Schedules an activity function for execution with retry options.
Sourcepub fn call_sub_orchestrator<D>(
&self,
function_name: &str,
instance_id: Option<String>,
data: D,
) -> ActionFuture<Result<Value, String>> ⓘ
pub fn call_sub_orchestrator<D>( &self, function_name: &str, instance_id: Option<String>, data: D, ) -> ActionFuture<Result<Value, String>> ⓘ
Schedules an orchestration function for execution.
Sourcepub fn call_sub_orchestrator_with_retry<D>(
&self,
function_name: &str,
instance_id: Option<String>,
data: D,
retry_options: RetryOptions,
) -> ActionFuture<Result<Value, String>> ⓘ
pub fn call_sub_orchestrator_with_retry<D>( &self, function_name: &str, instance_id: Option<String>, data: D, retry_options: RetryOptions, ) -> ActionFuture<Result<Value, String>> ⓘ
Schedules an orchestration function for execution with retry.
Sourcepub fn continue_as_new<D>(&self, input: D, preserve_unprocessed_events: bool)
pub fn continue_as_new<D>(&self, input: D, preserve_unprocessed_events: bool)
Restarts the orchestration by clearing its history.
Sourcepub fn create_timer(&self, fire_at: DateTime<Utc>) -> ActionFuture<()> ⓘ
pub fn create_timer(&self, fire_at: DateTime<Utc>) -> ActionFuture<()> ⓘ
Creates a durable timer that expires at a specified time.
Sourcepub fn wait_for_event(&self, name: &str) -> ActionFuture<Result<Value, String>> ⓘ
pub fn wait_for_event(&self, name: &str) -> ActionFuture<Result<Value, String>> ⓘ
Wait for an external event of the given name.
Auto Trait Implementations§
impl Freeze for DurableOrchestrationContext
impl !RefUnwindSafe for DurableOrchestrationContext
impl !Send for DurableOrchestrationContext
impl !Sync for DurableOrchestrationContext
impl Unpin for DurableOrchestrationContext
impl !UnwindSafe for DurableOrchestrationContext
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> 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