Skip to main content

Setup

Struct Setup 

Source
pub struct Setup { /* private fields */ }
Expand description

What a scenario’s setup function builds for one seed: the workflows, the client’s requests and the checks.

Implementations§

Source§

impl Setup

Source

pub fn seed(&self) -> u64

The seed being run.

Source

pub fn random(&mut self, n: u64) -> u64

A number below n from the seed, to vary the scenario per seed.

Source

pub fn register<I, O, F, Fut>( &mut self, workflow: impl AsWorkflow<I, O>, f: F, ) -> &mut Self
where I: Serialize + DeserializeOwned + 'static, O: Serialize + DeserializeOwned + 'static, F: Fn(Ctx, I) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<O, Error>> + 'static,

Registers a workflow type’s code (at the reference’s version, else version 1). Inputs and results are JSON, as with fusee::Engine::register.

Source

pub fn object(&mut self, name: &str, handlers: ObjectHandlers) -> &mut Self

Registers an object type with its handlers (see fusee::object). Its keys are called by the client (call) and by workflow code (ctx.object(type, key)).

Source

pub fn call( &mut self, at: Duration, wtype: &str, key: &str, handler: &str, call_id: &str, arg: &impl Serialize, ) -> &mut Self

The client calls handler of key key of object type wtype at at ([fusee::ObjectRef::call_with_id]). Until it is answered the client sends it again, across crashes, with the same call_id; the simulator fails the seed if two answers to one call ID differ (the call ran twice). Outcome::call has the answer.

Source

pub fn start( &mut self, at: Duration, id: &str, workflow: &str, input: &impl Serialize, ) -> &mut Self

The client starts id as a workflow at at after the simulation begins. Until it is acknowledged the client retries, across crashes, attaching to the existing run.

Source

pub fn signal( &mut self, at: Duration, id: &str, name: &str, payload: &impl Serialize, ) -> &mut Self

The client signals id once its start was acknowledged; retries carry one deduplication key, so the run receives it once.

Source

pub fn read_stream(&mut self, at: Duration, id: &str, name: &str) -> &mut Self

A client reads stream name of id from at on, to its end, connecting again at its offset after every crash. The simulator checks that every reader of a stream sees the same chunk at each offset (none changes or goes away after a crash), with no offset skipped; Outcome::stream has what they saw.

Source

pub fn cancel(&mut self, at: Duration, id: &str) -> &mut Self

The client cancels id.

Source

pub fn terminate(&mut self, at: Duration, id: &str) -> &mut Self

The client terminates id.

Source

pub fn debounce( &mut self, at: Duration, workflow: &str, key: &str, event_id: &str, input: &impl Serialize, rule: &Debounce, ) -> &mut Self

The client debounces a start of workflow under key at at ([fusee::Workflow::debounce_with_id]). Until it is acknowledged the client sends it again, across crashes, with the same event_id; the run it joined is in Outcome::receipt. The simulator checks that every acknowledged event’s run starts and finishes.

Source

pub fn batch( &mut self, at: Duration, workflow: &str, key: &str, event_id: &str, event: &impl Serialize, rule: &Batch, ) -> &mut Self

The client adds an event to workflow’s batch under key at at ([fusee::Workflow::batch_with_id]), retrying as for debounce.

Source

pub fn check( &mut self, f: impl FnOnce(&Outcome) -> Result<(), String> + 'static, ) -> &mut Self

Adds a check on the final results.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Setup

§

impl !Send for Setup

§

impl !Sync for Setup

§

impl !UnwindSafe for Setup

§

impl Forget for Setup

§

impl Freeze for Setup

§

impl Move for Setup

§

impl Unpin for Setup

§

impl UnsafeUnpin for Setup

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

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.