Skip to main content

Service

Struct Service 

Source
pub struct Service {
Show 13 fields pub calls: BTreeMap<String, Vec<u64>>, pub violations: Vec<String>, pub total: u64, pub seed: u64, pub progress: BTreeMap<String, BTreeSet<u32>>, pub stalled: BTreeSet<String>, pub tokens: Vec<(String, String)>, pub issued: BTreeMap<String, u32>, pub ticks: BTreeMap<String, BTreeSet<u64>>, pub reads: BTreeMap<String, Vec<u64>>, pub reads_rerun: u32, pub talk_calls: BTreeMap<String, u64>, pub talk_failed: BTreeSet<String>,
}
Expand description

A mock external service. It logs every call with its idempotency key and input. Responses differ per call, so a step that runs again yields a different value; if any later step had already run on the first value, the log shows one key called with two different inputs.

Fields§

§calls: BTreeMap<String, Vec<u64>>§violations: Vec<String>§total: u64§seed: u64§progress: BTreeMap<String, BTreeSet<u32>>

Progress each step key reported through heartbeats.

§stalled: BTreeSet<String>§tokens: Vec<(String, String)>

Completion tokens handed out, in order: (workflow ID, token).

§issued: BTreeMap<String, u32>§ticks: BTreeMap<String, BTreeSet<u64>>

Runs seen per scheduled workflow ID.

§reads: BTreeMap<String, Vec<u64>>

Inputs of read-only calls per key. Reads may run on state a crash takes back, so a key read with different inputs is allowed; it is counted to show that read-only steps really run ahead of the disk.

§reads_rerun: u32§talk_calls: BTreeMap<String, u64>

Tokens a model step asked for per key, and the keys whose call failed once.

§talk_failed: BTreeSet<String>

Implementations§

Source§

impl Service

Source

pub fn resume(&mut self, key: &str, start: u32)

A step resumed from heartbeat progress start: it must be progress the step reported (a crash may only take back newer progress).

Source

pub fn report_progress(&mut self, key: &str, p: u32)

Source

pub fn stall_once(&mut self, key: &str) -> bool

True once per key: the step stalls without heartbeats.

Source

pub fn issue(&mut self, wf: &str, token: &str) -> Result<(), String>

Hands out a completion token. The first attempt per workflow fails.

Source

pub fn tick(&mut self, wf: &str, run: u64)

Source

pub fn read( &mut self, key: &str, input: u64, fail_first: u32, ) -> Result<u64, String>

A read-only call: logged apart from calls with effects and never a violation. Answers differ per call like Service::call.

Source

pub fn token(&mut self, key: &str, i: usize) -> Result<u64, String>

A model’s next token: a new value on every call, as sampling gives (so a token generated again differs from the first). Fails once per even key at the third token.

Source

pub fn call( &mut self, key: &str, input: u64, fail_first: u32, ) -> Result<u64, String>

Trait Implementations§

Source§

impl Default for Service

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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