Skip to main content

TestExecutionOrchestrator

Struct TestExecutionOrchestrator 

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

Source

pub fn new<F, Fut>( handler: F, operation_storage: Arc<RwLock<OperationStorage>>, checkpoint_api: Arc<CheckpointWorkerManager>, skip_time_config: SkipTimeConfig, ) -> Self
where 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 execute
  • operation_storage - Shared storage for operations
  • checkpoint_api - The checkpoint API client
  • skip_time_config - Configuration for time skipping
Source

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 handles
  • shared_operations - Shared operations list for child enumeration
  • callback_sender - Callback sender for populating callback handles
Source

pub fn is_time_skipping_enabled(&self) -> bool

Check if time skipping is enabled.

Source

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

Get the current execution ID.

Source

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

Get the current checkpoint token.

Source

pub fn is_execution_complete(&self) -> bool

Check if execution is complete.

Source

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,

Source

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:

  1. Start execution via checkpoint API
  2. Begin polling for checkpoint updates
  3. Invoke handler
  4. Process operation updates (waits, callbacks, retries)
  5. Schedule re-invocations as needed
  6. Return result when execution completes
§Arguments
  • payload - The input payload to pass to the handler
Source

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 invoke
  • execution_id - The execution ID
  • operation_id - The operation ID to mark as SUCCEEDED before re-invoking
Source

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
Source

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.

Source

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 handler
  • execution_id - The execution ID
  • is_initial - Whether this is the initial invocation (vs a re-invocation)
§Returns

An InvokeHandlerResult indicating the outcome of the invocation.

Source

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.

Source

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§

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> 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, 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