Skip to main content

Workload

Trait Workload 

Source
pub trait Workload: 'static {
    // Required methods
    fn name(&self) -> &str;
    fn run<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        ctx: &'life1 SimContext,
    ) -> Pin<Box<dyn Future<Output = SimulationResult<()>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn setup<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 SimContext,
    ) -> Pin<Box<dyn Future<Output = SimulationResult<()>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn check<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 SimContext,
    ) -> Pin<Box<dyn Future<Output = SimulationResult<()>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

A workload that participates in simulation testing.

Workloads are the primary unit of distributed system behavior. The simulation framework calls lifecycle methods in order: setupruncheck.

Required Methods§

Source

fn name(&self) -> &str

Name of this workload for topology and reporting.

Source

fn run<'life0, 'life1, 'async_trait>( &'life0 mut self, ctx: &'life1 SimContext, ) -> Pin<Box<dyn Future<Output = SimulationResult<()>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Run phase: main workload logic.

All workloads run concurrently. Ends on completion or shutdown signal.

Provided Methods§

Source

fn setup<'life0, 'life1, 'async_trait>( &'life0 mut self, _ctx: &'life1 SimContext, ) -> Pin<Box<dyn Future<Output = SimulationResult<()>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Setup phase: bind listeners, initialize state.

All workloads complete setup before any run() starts. Default implementation is a no-op.

Source

fn check<'life0, 'life1, 'async_trait>( &'life0 mut self, _ctx: &'life1 SimContext, ) -> Pin<Box<dyn Future<Output = SimulationResult<()>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check phase: validate correctness after quiescence.

Called after all runs complete and pending events drain. Default implementation is a no-op.

Implementors§