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
impl DurableOperation
Sourcepub fn new(operation: Operation) -> Self
pub fn new(operation: Operation) -> Self
Creates a new DurableOperation wrapping the given SDK operation.
Sourcepub fn with_callback_sender(
operation: Operation,
callback_sender: Arc<dyn CallbackSender>,
) -> Self
pub fn with_callback_sender( operation: Operation, callback_sender: Arc<dyn CallbackSender>, ) -> Self
Creates a new DurableOperation with a callback sender.
Sourcepub fn with_status_watcher(
operation: Operation,
status_watcher: Receiver<OperationStatus>,
) -> Self
pub fn with_status_watcher( operation: Operation, status_watcher: Receiver<OperationStatus>, ) -> Self
Creates a new DurableOperation with a status watcher.
Sourcepub fn with_all(
operation: Operation,
callback_sender: Option<Arc<dyn CallbackSender>>,
status_watcher: Option<Receiver<OperationStatus>>,
) -> Self
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.
Sourcepub fn get_parent_id(&self) -> Option<&str>
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.
Sourcepub fn get_type(&self) -> OperationType
pub fn get_type(&self) -> OperationType
Gets the operation type.
§Returns
The type of operation (Step, Wait, Callback, Invoke, Context, Execution).
Sourcepub fn get_status(&self) -> OperationStatus
pub fn get_status(&self) -> OperationStatus
Sourcepub fn get_start_timestamp(&self) -> Option<DateTime<Utc>>
pub fn get_start_timestamp(&self) -> Option<DateTime<Utc>>
Sourcepub fn get_end_timestamp(&self) -> Option<DateTime<Utc>>
pub fn get_end_timestamp(&self) -> Option<DateTime<Utc>>
Sourcepub fn get_operation_data(&self) -> &Operation
pub fn get_operation_data(&self) -> &Operation
Sourcepub fn is_callback(&self) -> bool
pub fn is_callback(&self) -> bool
Sourcepub fn is_completed(&self) -> bool
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).
Sourcepub fn is_succeeded(&self) -> bool
pub fn is_succeeded(&self) -> bool
Sourcepub fn is_failed(&self) -> bool
pub fn is_failed(&self) -> bool
Checks if the operation failed.
§Returns
True if the operation status is Failed, Cancelled, or TimedOut.
Sourcepub fn with_operations(self, all_operations: Arc<Vec<Operation>>) -> Self
pub fn with_operations(self, all_operations: Arc<Vec<Operation>>) -> Self
Sets the shared reference to all operations for child enumeration.
Source§impl DurableOperation
impl DurableOperation
Sourcepub fn get_child_operations(&self) -> Vec<DurableOperation>
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.
§Requirements
- 8.1: Returns all operations whose parent_id matches this operation’s id
- 8.2: Returns empty Vec when no children exist
- 8.3: Returned operations ordered by their position in the operations list
Source§impl DurableOperation
impl DurableOperation
Sourcepub fn get_step_details<T: DeserializeOwned>(
&self,
) -> Result<StepDetails<T>, TestError>
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 operationErr(TestError)- Error if this is not a Step operation
§Requirements
- 5.1: WHEN a developer calls get_step_details() on a Step operation, THE Durable_Operation SHALL return attempt count, result, and error information
- 5.6: IF a developer calls a type-specific method on the wrong operation type, THEN THE Durable_Operation SHALL return an error
Sourcepub fn get_wait_details(&self) -> Result<WaitDetails, TestError>
pub fn get_wait_details(&self) -> Result<WaitDetails, TestError>
Gets wait-specific details.
§Returns
Ok(WaitDetails)- The wait details if this is a Wait operationErr(TestError)- Error if this is not a Wait operation
§Requirements
- 5.2: WHEN a developer calls get_wait_details() on a Wait operation, THE Durable_Operation SHALL return the wait duration and scheduled end timestamp
- 5.6: IF a developer calls a type-specific method on the wrong operation type, THEN THE Durable_Operation SHALL return an error
Sourcepub fn get_callback_details<T: DeserializeOwned>(
&self,
) -> Result<CallbackDetails<T>, TestError>
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 operationErr(TestError)- Error if this is not a Callback operation
§Requirements
- 5.3: WHEN a developer calls get_callback_details() on a Callback operation, THE Durable_Operation SHALL return the callback ID, result, and error
- 5.6: IF a developer calls a type-specific method on the wrong operation type, THEN THE Durable_Operation SHALL return an error
Sourcepub fn get_invoke_details<T: DeserializeOwned>(
&self,
) -> Result<InvokeDetails<T>, TestError>
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 operationErr(TestError)- Error if this is not an Invoke operation
§Requirements
- 5.4: WHEN a developer calls get_invoke_details() on an Invoke operation, THE Durable_Operation SHALL return the invocation result and error
- 5.6: IF a developer calls a type-specific method on the wrong operation type, THEN THE Durable_Operation SHALL return an error
Sourcepub fn get_context_details<T: DeserializeOwned>(
&self,
) -> Result<ContextDetails<T>, TestError>
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 operationErr(TestError)- Error if this is not a Context operation
§Requirements
- 5.5: WHEN a developer calls get_context_details() on a Context operation, THE Durable_Operation SHALL return the context result and error
- 5.6: IF a developer calls a type-specific method on the wrong operation type, THEN THE Durable_Operation SHALL return an error
Source§impl DurableOperation
impl DurableOperation
Sourcepub async fn send_callback_success(&self, result: &str) -> Result<(), TestError>
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 successfullyErr(TestError)- If this is not a callback operation or sending failed
§Requirements
- 6.1: WHEN a developer calls send_callback_success(result) on a callback operation, THE Durable_Operation SHALL send a success response to the checkpoint service
- 6.4: IF a developer calls callback methods on a non-callback operation, THEN THE Durable_Operation SHALL return an error
Sourcepub async fn send_callback_failure(
&self,
error: &TestResultError,
) -> Result<(), TestError>
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 successfullyErr(TestError)- If this is not a callback operation or sending failed
§Requirements
- 6.2: WHEN a developer calls send_callback_failure(error) on a callback operation, THE Durable_Operation SHALL send a failure response to the checkpoint service
- 6.4: IF a developer calls callback methods on a non-callback operation, THEN THE Durable_Operation SHALL return an error
Sourcepub async fn send_callback_heartbeat(&self) -> Result<(), TestError>
pub async fn send_callback_heartbeat(&self) -> Result<(), TestError>
Sends a heartbeat for a callback operation.
§Returns
Ok(())- If the heartbeat was sent successfullyErr(TestError)- If this is not a callback operation or sending failed
§Requirements
- 6.3: WHEN a developer calls send_callback_heartbeat() on a callback operation, THE Durable_Operation SHALL send a heartbeat to keep the callback active
- 6.4: IF a developer calls callback methods on a non-callback operation, THEN THE Durable_Operation SHALL return an error
Source§impl DurableOperation
impl DurableOperation
Sourcepub async fn wait_for_data(
&self,
target_status: WaitingOperationStatus,
) -> Result<&Self, TestError>
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 reachedErr(TestError)- If the execution completes before reaching the target status
§Requirements
- 10.1: WHEN a developer calls wait_for_data() on a Durable_Operation, THE Durable_Operation SHALL return a future that resolves when the operation has started
- 10.2: WHEN a developer calls wait_for_data(WaitingStatus::Completed) on a Durable_Operation, THE Durable_Operation SHALL return a future that resolves when the operation has completed
- 10.3: WHEN a developer calls wait_for_data(WaitingStatus::Submitted) on a callback operation, THE Durable_Operation SHALL return a future that resolves when the callback is ready to receive responses
- 10.4: IF the execution completes before the operation reaches the requested state, THEN THE Durable_Operation SHALL return an error
Trait Implementations§
Source§impl Clone for DurableOperation
impl Clone for DurableOperation
Auto Trait Implementations§
impl Freeze for DurableOperation
impl !RefUnwindSafe for DurableOperation
impl Send for DurableOperation
impl Sync for DurableOperation
impl Unpin for DurableOperation
impl UnsafeUnpin for DurableOperation
impl !UnwindSafe for DurableOperation
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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