Struct DurableOrchestrationContext

Source
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:

NameDescription
nameThe name of the parameter being bound.
orchestrationThe 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

Source

pub fn is_replaying(&self) -> bool

Gets a value indicating whether the orchestrator function is currently replaying itself.

Source

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

Gets the current date/time in a way that is safe for use by orchestrator functions.

Source

pub fn set_custom_status<S>(&self, status: S)
where S: Into<Value>,

Sets the custom status of the orchestration.

Source

pub fn new_guid(&self) -> Uuid

Create a new deterministic GUID suitable for use with orchestrations.

Source

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.

Source

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.

Source

pub fn call_activity<D>( &self, activity_name: &str, data: D, ) -> ActionFuture<Result<Value, String>>
where D: Into<Value>,

Schedules an activity function for execution.

Source

pub fn call_activity_with_retry<D>( &self, activity_name: &str, data: D, retry_options: RetryOptions, ) -> ActionFuture<Result<Value, String>>
where D: Into<Value>,

Schedules an activity function for execution with retry options.

Source

pub fn call_sub_orchestrator<D>( &self, function_name: &str, instance_id: Option<String>, data: D, ) -> ActionFuture<Result<Value, String>>
where D: Into<Value>,

Schedules an orchestration function for execution.

Source

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>>
where D: Into<Value>,

Schedules an orchestration function for execution with retry.

Source

pub fn continue_as_new<D>(&self, input: D, preserve_unprocessed_events: bool)
where D: Into<Value>,

Restarts the orchestration by clearing its history.

Source

pub fn create_timer(&self, fire_at: DateTime<Utc>) -> ActionFuture<()>

Creates a durable timer that expires at a specified time.

Source

pub fn wait_for_event(&self, name: &str) -> ActionFuture<Result<Value, String>>

Wait for an external event of the given name.

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> 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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
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