pub struct Scenario<C> {
pub config: Config,
pub nodes: Vec<NodeId>,
pub steps: Vec<(Duration, Step<C>)>,
pub horizon: Duration,
}Expand description
A whole run, as data.
Executing one twice produces the same trace, by the determinism the simulator already guarantees: the configuration carries the seed, and nothing else in a run is drawn from anywhere but the generator that seed starts.
Fields§
§config: ConfigNetwork conditions and the seed. The seed lives here rather than beside it, because it is what the simulator already treats as part of a configuration.
nodes: Vec<NodeId>The processes in the run.
steps: Vec<(Duration, Step<C>)>What happens, and when — each time measured from the start of the run, in non-decreasing order. Two steps at the same time happen in the order given, with nothing dispatched between them.
horizon: DurationHow long to run after the last step.
Implementations§
Source§impl<C> Scenario<C>
impl<C> Scenario<C>
Sourcepub fn new(config: Config, nodes: impl IntoIterator<Item = NodeId>) -> Self
pub fn new(config: Config, nodes: impl IntoIterator<Item = NodeId>) -> Self
An empty run over nodes with no steps and no horizon.
Sourcepub fn at(self, at: Duration, step: Step<C>) -> Self
pub fn at(self, at: Duration, step: Step<C>) -> Self
Add a step at at, measured from the start of the run.
§Panics
If at precedes the last step already added. A description is executed in the order it
is written, and the clock does not go backwards, so an out-of-order step would silently
happen at the wrong moment rather than where it reads.
Source§impl<C: Clone> Scenario<C>
impl<C: Clone> Scenario<C>
Sourcepub fn is_well_formed(&self) -> boolwhere
C: PartialEq,
pub fn is_well_formed(&self) -> boolwhere
C: PartialEq,
Whether every Resume has a Suspend and every Restart a Crash, in order.
A scenario written by hand can be wrong; one produced by a reduction cannot, because every reduction repairs. Exposed so a test can say which it is holding.
Source§impl<C: Debug> Scenario<C>
impl<C: Debug> Scenario<C>
Sourcepub fn to_rust(&self, name: &str) -> String
pub fn to_rust(&self, name: &str) -> String
Render as Rust that reconstructs this scenario, as a function named name.
The end of a reduction should be something to paste, not something to transcribe. The
command is rendered with its Debug, which is valid Rust for the derived implementations
this repository’s commands all use, provided their variants are in scope where the output
is pasted.