pub struct WorkflowEnvironment { /* private fields */ }Expand description
In-process workflow/activity registration and recorded-history replay.
Implementations§
Source§impl WorkflowEnvironment
impl WorkflowEnvironment
Sourcepub fn from_worker(worker: Worker) -> Self
pub fn from_worker(worker: Worker) -> Self
Reuse an application’s complete registered workflow/activity set. Execution methods on this environment do not use the Worker’s transport.
Sourcepub fn worker_mut(&mut self) -> &mut Worker
pub fn worker_mut(&mut self) -> &mut Worker
Access all existing typed, lossless and replayed-state registration APIs.
pub fn register_workflow<F, Fut>(&mut self, name: impl Into<String>, handler: F)
pub fn register_workflow_avro_value<F, Fut>( &mut self, name: impl Into<String>, handler: F, )
pub fn register_activity<F, Fut>(&mut self, name: impl Into<String>, handler: F)
pub fn register_activity_avro_value<F, Fut>( &mut self, name: impl Into<String>, handler: F, )
Sourcepub fn mock_activity<F, Fut>(&mut self, name: impl Into<String>, handler: F)
pub fn mock_activity<F, Fut>(&mut self, name: impl Into<String>, handler: F)
Explicitly replace an activity callback for this environment, retaining the production Worker’s duplicate-registration checks for real handlers.
Sourcepub fn mock_activity_avro_value<F, Fut>(
&mut self,
name: impl Into<String>,
handler: F,
)
pub fn mock_activity_avro_value<F, Fut>( &mut self, name: impl Into<String>, handler: F, )
Lossless fixed-Avro counterpart to Self::mock_activity.
pub fn max_steps(self, limit: usize) -> Self
pub fn last_history(&self) -> Option<&WorkflowHistory>
Sourcepub fn replay(&self, history: &WorkflowHistory) -> Result<ReplayReport>
pub fn replay(&self, history: &WorkflowHistory) -> Result<ReplayReport>
Replay through the worker’s codec, durable-command and marker paths. Newly emitted durable commands are divergences, including commands added after the recorded history ended. No activity callbacks are invoked.
Source§impl WorkflowEnvironment
impl WorkflowEnvironment
Sourcepub async fn run_activity<T: Serialize>(
&self,
name: &str,
input: T,
) -> Result<Value>
pub async fn run_activity<T: Serialize>( &self, name: &str, input: T, ) -> Result<Value>
Run one registered activity attempt, including its normal argument/result conversion. Heartbeats are captured locally. This method does not retry; workflow execution applies the workflow’s activity retry policy.
pub async fn run_activity_avro_value( &self, name: &str, input: AvroValue, ) -> Result<AvroValue>
Sourcepub async fn run_workflow<T: Serialize>(
&mut self,
name: &str,
input: T,
) -> Result<Value>
pub async fn run_workflow<T: Serialize>( &mut self, name: &str, input: T, ) -> Result<Value>
Run a new workflow without a Server, returning its result or original typed failure. Each durable turn uses the worker’s cold-replay engine. Activity retry delays and durable timers are skipped. Registered activity handlers run normally and may be replaced by test callbacks.
External services, signals, child workflows, sessions, cancellation and activity timeout simulation require a live integration test; unsupported commands fail explicitly. Parallel activity handlers run in command order.