Skip to main content

DurableOperation

Struct DurableOperation 

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

A durable operation with inspection and interaction methods.

Wraps an SDK Operation and provides type-specific inspection methods and callback interaction capabilities for testing.

§Examples

use durable_execution_sdk_testing::DurableOperation;

// Get operation from test runner
let op = runner.get_operation("my-step").unwrap();

// Inspect basic properties
println!("ID: {}", op.get_id());
println!("Type: {}", op.get_type());
println!("Status: {}", op.get_status());

// Get type-specific details
if op.get_type() == OperationType::Step {
    let details = op.get_step_details::<String>().unwrap();
    println!("Result: {:?}", details.result);
}

Implementations§

Source§

impl DurableOperation

Source

pub fn new(operation: Operation) -> Self

Creates a new DurableOperation wrapping the given SDK operation.

Source

pub fn with_callback_sender( operation: Operation, callback_sender: Arc<dyn CallbackSender>, ) -> Self

Creates a new DurableOperation with a callback sender.

Source

pub fn with_status_watcher( operation: Operation, status_watcher: Receiver<OperationStatus>, ) -> Self

Creates a new DurableOperation with a status watcher.

Source

pub fn with_all( operation: Operation, callback_sender: Option<Arc<dyn CallbackSender>>, status_watcher: Option<Receiver<OperationStatus>>, ) -> Self

Creates a new DurableOperation with both callback sender and status watcher.

Source

pub fn get_id(&self) -> &str

Gets the operation ID.

§Returns

The unique identifier for this operation.

Source

pub fn get_parent_id(&self) -> Option<&str>

Gets the parent operation ID.

§Returns

The parent operation ID if this is a nested operation, None otherwise.

Source

pub fn get_name(&self) -> Option<&str>

Gets the operation name.

§Returns

The human-readable name if set, None otherwise.

Source

pub fn get_type(&self) -> OperationType

Gets the operation type.

§Returns

The type of operation (Step, Wait, Callback, Invoke, Context, Execution).

Source

pub fn get_status(&self) -> OperationStatus

Gets the operation status.

§Returns

The current status of the operation.

Source

pub fn get_start_timestamp(&self) -> Option<DateTime<Utc>>

Gets the start timestamp.

§Returns

The start timestamp as a DateTime if available.

Source

pub fn get_end_timestamp(&self) -> Option<DateTime<Utc>>

Gets the end timestamp.

§Returns

The end timestamp as a DateTime if available.

Source

pub fn get_operation_data(&self) -> &Operation

Gets the raw operation data.

§Returns

A reference to the underlying SDK Operation.

Source

pub fn is_callback(&self) -> bool

Checks if this is a callback operation.

§Returns

True if this operation is of type Callback.

Source

pub fn is_completed(&self) -> bool

Checks if the operation has completed.

§Returns

True if the operation status is terminal (Succeeded, Failed, Cancelled, TimedOut, Stopped).

Source

pub fn is_succeeded(&self) -> bool

Checks if the operation succeeded.

§Returns

True if the operation status is Succeeded.

Source

pub fn is_failed(&self) -> bool

Checks if the operation failed.

§Returns

True if the operation status is Failed, Cancelled, or TimedOut.

Source

pub fn with_operations(self, all_operations: Arc<Vec<Operation>>) -> Self

Sets the shared reference to all operations for child enumeration.

Source§

impl DurableOperation

Source

pub fn get_child_operations(&self) -> Vec<DurableOperation>

Returns all child operations nested under this operation.

Child operations are those whose parent_id matches this operation’s id. The returned operations are ordered by their position in the operations list.

§Returns

A vector of DurableOperation instances representing child operations. Returns an empty vector if no children exist or if the operations list is not available.

Source§

impl DurableOperation

Source

pub 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 this is a Step operation
  • Err(TestError) - Error if this is not a Step operation
Source

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

Gets wait-specific details.

§Returns
  • Ok(WaitDetails) - The wait details if this is a Wait operation
  • Err(TestError) - Error if this is not a Wait operation
Source

pub 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 this is a Callback operation
  • Err(TestError) - Error if this is not a Callback operation
Source

pub 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 this is an Invoke operation
  • Err(TestError) - Error if this is not an Invoke operation
Source

pub 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 this is a Context operation
  • Err(TestError) - Error if this is not a Context operation
Source§

impl DurableOperation

Source

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

Sends a success response for a callback operation.

§Arguments
  • result - The result value to send as a JSON string
§Returns
  • Ok(()) - If the callback response was sent successfully
  • Err(TestError) - If this is not a callback operation or sending failed
Source

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

Sends a failure response for a callback operation.

§Arguments
  • error - The error information to send
§Returns
  • Ok(()) - If the callback response was sent successfully
  • Err(TestError) - If this is not a callback operation or sending failed
Source

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

Sends a heartbeat for a callback operation.

§Returns
  • Ok(()) - If the heartbeat was sent successfully
  • Err(TestError) - If this is not a callback operation or sending failed
Source§

impl DurableOperation

Source

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

Waits for the operation to reach a specific status.

§Arguments
  • target_status - The status to wait for
§Returns
  • Ok(&Self) - Reference to self when the target status is reached
  • Err(TestError) - If the execution completes before reaching the target status

Trait Implementations§

Source§

impl Clone for DurableOperation

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

impl Debug for DurableOperation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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