Skip to main content

OperationHandle

Struct OperationHandle 

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

A lazy handle to an operation that will be populated during execution.

Registered before run() via get_operation_handle(), get_operation_handle_by_index(), or get_operation_handle_by_id() on the LocalDurableTestRunner. The handle starts unpopulated and is filled with operation data when the orchestrator finds a matching operation during execution.

§Examples

use durable_execution_sdk_testing::OperationHandle;

// Pre-register a handle before run()
let handle = runner.get_operation_handle("my-callback");

// Start non-blocking execution
let future = runner.run(input);

// Wait for the operation to reach Submitted status
handle.wait_for_data(WaitingOperationStatus::Submitted).await?;

// Send callback response
handle.send_callback_success("result").await?;

// Await the final result
let result = future.await?;

Implementations§

Source§

impl OperationHandle

Source

pub fn new( matcher: OperationMatcher, all_operations: Arc<RwLock<Vec<Operation>>>, ) -> Self

Creates a new unpopulated OperationHandle with the given matcher.

The handle starts with no operation data. It will be populated during execution when the orchestrator finds an operation matching the matcher.

§Arguments
  • matcher - How this handle should match against operations
  • all_operations - Shared reference to all operations for child enumeration
Source

pub async fn get_id(&self) -> Result<String, TestError>

Gets the operation ID.

§Returns
  • Ok(String) - The operation ID if the handle is populated
  • Err(TestError::OperationNotFound) - If the handle is not yet populated
Source

pub async fn get_name(&self) -> Result<Option<String>, TestError>

Gets the operation name.

§Returns
  • Ok(Option<String>) - The operation name if the handle is populated
  • Err(TestError::OperationNotFound) - If the handle is not yet populated
Source

pub async fn get_type(&self) -> Result<OperationType, TestError>

Gets the operation type.

§Returns
  • Ok(OperationType) - The operation type if the handle is populated
  • Err(TestError::OperationNotFound) - If the handle is not yet populated
Source

pub async fn get_status(&self) -> Result<OperationStatus, TestError>

Gets the operation status.

§Returns
  • Ok(OperationStatus) - The operation status if the handle is populated
  • Err(TestError::OperationNotFound) - If the handle is not yet populated
Source

pub async fn get_step_details<T: DeserializeOwned>( &self, ) -> Result<StepDetails<T>, TestError>

Gets step-specific details.

§Type Parameters
  • T - The type to deserialize the result into
§Returns
  • Ok(StepDetails<T>) - The step details if populated and is a Step operation
  • Err(TestError) - If unpopulated or wrong operation type
Source

pub async fn get_callback_details<T: DeserializeOwned>( &self, ) -> Result<CallbackDetails<T>, TestError>

Gets callback-specific details.

§Type Parameters
  • T - The type to deserialize the result into
§Returns
  • Ok(CallbackDetails<T>) - The callback details if populated and is a Callback operation
  • Err(TestError) - If unpopulated or wrong operation type
Source

pub async fn get_wait_details(&self) -> Result<WaitDetails, TestError>

Gets wait-specific details.

§Returns
  • Ok(WaitDetails) - The wait details if populated and is a Wait operation
  • Err(TestError) - If unpopulated or wrong operation type
Source

pub async fn get_invoke_details<T: DeserializeOwned>( &self, ) -> Result<InvokeDetails<T>, TestError>

Gets invoke-specific details.

§Type Parameters
  • T - The type to deserialize the result into
§Returns
  • Ok(InvokeDetails<T>) - The invoke details if populated and is an Invoke operation
  • Err(TestError) - If unpopulated or wrong operation type
Source

pub async fn get_context_details<T: DeserializeOwned>( &self, ) -> Result<ContextDetails<T>, TestError>

Gets context-specific details.

§Type Parameters
  • T - The type to deserialize the result into
§Returns
  • Ok(ContextDetails<T>) - The context details if populated and is a Context operation
  • Err(TestError) - If unpopulated or wrong operation type
Source

pub async fn is_populated(&self) -> bool

Checks if the handle has been populated with operation data.

§Returns

true if the handle has been populated, false otherwise.

Source

pub async fn wait_for_data( &self, status: WaitingOperationStatus, ) -> Result<(), TestError>

Waits for the operation to reach the specified WaitingOperationStatus.

Resolves immediately if the operation has already reached the target status. If the watch channel closes (execution ended) before the target status is reached, returns Err(TestError::ExecutionCompletedEarly(...)).

§Arguments
  • status - The target status to wait for
§Returns
  • Ok(()) - When the operation reaches the target status
  • Err(TestError::ExecutionCompletedEarly) - If execution ends before reaching the target
§Examples
// Wait for a callback to be ready for responses
handle.wait_for_data(WaitingOperationStatus::Submitted).await?;

// Wait for an operation to complete
handle.wait_for_data(WaitingOperationStatus::Completed).await?;
Source

pub async fn send_callback_success(&self, result: &str) -> Result<(), TestError>

Sends a success response for a callback operation.

Validates that the handle is populated, the operation is a callback type, and the callback_id is available (Submitted status) before delegating to the callback sender.

§Arguments
  • result - The result value to send as a JSON string
§Returns
  • Ok(()) - If the callback response was sent successfully
  • Err(TestError::OperationNotFound) - If the handle is not yet populated
  • Err(TestError::NotCallbackOperation) - If the operation is not a callback
  • Err(TestError::ResultNotAvailable) - If the callback_id is not yet available
Source

pub async fn send_callback_failure( &self, error: &TestResultError, ) -> Result<(), TestError>

Sends a failure response for a callback operation.

Validates that the handle is populated, the operation is a callback type, and the callback_id is available (Submitted status) before delegating to the callback sender.

§Arguments
  • error - The error information to send
§Returns
  • Ok(()) - If the callback failure was sent successfully
  • Err(TestError::OperationNotFound) - If the handle is not yet populated
  • Err(TestError::NotCallbackOperation) - If the operation is not a callback
  • Err(TestError::ResultNotAvailable) - If the callback_id is not yet available
Source

pub async fn send_callback_heartbeat(&self) -> Result<(), TestError>

Sends a heartbeat for a callback operation.

Validates that the handle is populated, the operation is a callback type, and the callback_id is available (Submitted status) before delegating to the callback sender.

§Returns
  • Ok(()) - If the heartbeat was sent successfully
  • Err(TestError::OperationNotFound) - If the handle is not yet populated
  • Err(TestError::NotCallbackOperation) - If the operation is not a callback
  • Err(TestError::ResultNotAvailable) - If the callback_id is not yet available
Source

pub async fn get_child_operations( &self, ) -> Result<Vec<DurableOperation>, TestError>

Returns all child operations nested under this operation.

Child operations are those whose parent_id matches this operation’s id. The returned operations preserve execution order (same order as in the shared operations list).

§Returns
  • Ok(Vec<DurableOperation>) - Child operations if the handle is populated
  • Err(TestError::OperationNotFound) - If the handle is not yet populated

Trait Implementations§

Source§

impl Clone for OperationHandle

Source§

fn clone(&self) -> Self

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

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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