pub struct TestExecutionOrchestrator<I, O>where
I: DeserializeOwned + Send + Serialize + 'static,
O: Serialize + DeserializeOwned + Send + 'static,{ /* private fields */ }Expand description
Orchestrates test execution lifecycle, polling, and handler invocation.
This struct manages the full execution lifecycle including:
- Starting executions via checkpoint API
- Polling for checkpoint updates
- Processing operation updates (waits, callbacks, retries)
- Scheduling handler re-invocations
- Resolving execution when complete
Implementations§
Source§impl<I, O> TestExecutionOrchestrator<I, O>where
I: DeserializeOwned + Send + Serialize + Clone + 'static,
O: Serialize + DeserializeOwned + Send + 'static,
impl<I, O> TestExecutionOrchestrator<I, O>where
I: DeserializeOwned + Send + Serialize + Clone + 'static,
O: Serialize + DeserializeOwned + Send + 'static,
Sourcepub fn new<F, Fut>(
handler: F,
operation_storage: Arc<RwLock<OperationStorage>>,
checkpoint_api: Arc<CheckpointWorkerManager>,
skip_time_config: SkipTimeConfig,
) -> Selfwhere
F: Fn(I, DurableContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<O, DurableError>> + Send + 'static,
pub fn new<F, Fut>(
handler: F,
operation_storage: Arc<RwLock<OperationStorage>>,
checkpoint_api: Arc<CheckpointWorkerManager>,
skip_time_config: SkipTimeConfig,
) -> Selfwhere
F: Fn(I, DurableContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<O, DurableError>> + Send + 'static,
Create a new orchestrator.
§Arguments
handler- The handler function to executeoperation_storage- Shared storage for operationscheckpoint_api- The checkpoint API clientskip_time_config- Configuration for time skipping
Sourcepub fn with_handles(
self,
handles: Vec<OperationHandle>,
shared_operations: Arc<RwLock<Vec<Operation>>>,
callback_sender: Option<Arc<dyn CallbackSender>>,
) -> Self
pub fn with_handles( self, handles: Vec<OperationHandle>, shared_operations: Arc<RwLock<Vec<Operation>>>, callback_sender: Option<Arc<dyn CallbackSender>>, ) -> Self
Set the pre-registered operation handles for lazy population during execution.
§Arguments
handles- The pre-registered operation handlesshared_operations- Shared operations list for child enumerationcallback_sender- Callback sender for populating callback handles
Sourcepub fn is_time_skipping_enabled(&self) -> bool
pub fn is_time_skipping_enabled(&self) -> bool
Check if time skipping is enabled.
Sourcepub fn execution_id(&self) -> Option<&str>
pub fn execution_id(&self) -> Option<&str>
Get the current execution ID.
Sourcepub fn checkpoint_token(&self) -> Option<&str>
pub fn checkpoint_token(&self) -> Option<&str>
Get the current checkpoint token.
Sourcepub fn is_execution_complete(&self) -> bool
pub fn is_execution_complete(&self) -> bool
Check if execution is complete.
Sourcepub fn is_invocation_active(&self) -> bool
pub fn is_invocation_active(&self) -> bool
Check if an invocation is currently active.
Source§impl<I, O> TestExecutionOrchestrator<I, O>where
I: DeserializeOwned + Send + Serialize + Clone + 'static,
O: Serialize + DeserializeOwned + Send + 'static,
impl<I, O> TestExecutionOrchestrator<I, O>where
I: DeserializeOwned + Send + Serialize + Clone + 'static,
O: Serialize + DeserializeOwned + Send + 'static,
Sourcepub async fn execute_handler(
&mut self,
payload: I,
) -> Result<TestExecutionResult<O>, TestError>
pub async fn execute_handler( &mut self, payload: I, ) -> Result<TestExecutionResult<O>, TestError>
Execute the handler and return the result.
This method orchestrates the full execution lifecycle:
- Start execution via checkpoint API
- Begin polling for checkpoint updates
- Invoke handler
- Process operation updates (waits, callbacks, retries)
- Schedule re-invocations as needed
- Return result when execution completes
§Arguments
payload- The input payload to pass to the handler
Sourcepub fn schedule_invocation_at_timestamp(
&mut self,
timestamp_ms: i64,
execution_id: &str,
operation_id: &str,
)
pub fn schedule_invocation_at_timestamp( &mut self, timestamp_ms: i64, execution_id: &str, operation_id: &str, )
Schedule handler re-invocation at a specific timestamp.
This method schedules a handler re-invocation via the scheduler. When time skipping is enabled, it advances tokio time before invocation. It also updates checkpoint data (marks the operation as SUCCEEDED) before re-invoking.
§Arguments
timestamp_ms- The timestamp in milliseconds since epoch when to invokeexecution_id- The execution IDoperation_id- The operation ID to mark as SUCCEEDED before re-invoking
Sourcepub fn schedule_invocation_with_update(
&mut self,
timestamp: Option<DateTime<Utc>>,
update_checkpoint: Option<CheckpointUpdateFn>,
)
pub fn schedule_invocation_with_update( &mut self, timestamp: Option<DateTime<Utc>>, update_checkpoint: Option<CheckpointUpdateFn>, )
Schedule handler re-invocation at a specific timestamp with a custom checkpoint update.
This is a more flexible version that allows specifying a custom checkpoint update function.
§Arguments
timestamp- The timestamp when to invoke (optional, None for immediate)update_checkpoint- Optional function to update checkpoint data before invocation
Sourcepub fn has_scheduled_functions(&self) -> bool
pub fn has_scheduled_functions(&self) -> bool
Check if there are scheduled functions pending.
§Returns
true if there are scheduled functions waiting to be executed.
Sourcepub async fn invoke_handler(
&mut self,
payload: I,
execution_id: &str,
is_initial: bool,
) -> Result<InvokeHandlerResult<O>, TestError>
pub async fn invoke_handler( &mut self, payload: I, execution_id: &str, is_initial: bool, ) -> Result<InvokeHandlerResult<O>, TestError>
Invoke the handler and process the result.
This method handles a single handler invocation, including:
- Checking for active invocations (prevents concurrent invocations in time-skip mode)
- Starting invocation via checkpoint API
- Invoking handler with checkpoint token and operations
- Processing handler result (PENDING, SUCCEEDED, FAILED)
- Scheduling re-invocation if dirty operations exist
§Arguments
payload- The input payload to pass to the handlerexecution_id- The execution IDis_initial- Whether this is the initial invocation (vs a re-invocation)
§Returns
An InvokeHandlerResult indicating the outcome of the invocation.
Sourcepub fn flush_scheduled_functions(&mut self)
pub fn flush_scheduled_functions(&mut self)
Flush all scheduled functions without executing them.
This is useful for cleanup when execution completes or is cancelled.
Sourcepub async fn process_next_scheduled(&mut self) -> bool
pub async fn process_next_scheduled(&mut self) -> bool
Process the next scheduled function.
§Returns
true if a function was processed, false if the queue is empty.
Auto Trait Implementations§
impl<I, O> Freeze for TestExecutionOrchestrator<I, O>
impl<I, O> !RefUnwindSafe for TestExecutionOrchestrator<I, O>
impl<I, O> Send for TestExecutionOrchestrator<I, O>
impl<I, O> !Sync for TestExecutionOrchestrator<I, O>
impl<I, O> Unpin for TestExecutionOrchestrator<I, O>
impl<I, O> UnsafeUnpin for TestExecutionOrchestrator<I, O>
impl<I, O> !UnwindSafe for TestExecutionOrchestrator<I, O>
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> 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