pub struct IntentMachine {
pub store: ClientStore,
pub attempts: u32,
pub backoff_ms: Vec<u64>,
}Fields§
§store: ClientStore§attempts: u32§backoff_ms: Vec<u64>Implementations§
Source§impl IntentMachine
impl IntentMachine
pub fn new(store: ClientStore, attempts: u32, backoff_ms: Vec<u64>) -> Self
Sourcepub fn enqueue(&self, envelope: &Envelope) -> Result<bool>
pub fn enqueue(&self, envelope: &Envelope) -> Result<bool>
Queue one envelope under the id its row is keyed by.
A kind that may arrive without a key (a note) gets a fresh one from
stamp_op_id, and the stamped envelope is what the row stores and
replays, so the row’s op_id and its env_json never disagree.
pub fn enqueue_value(&self, op_id: &str, envelope: &Value) -> Result<bool>
Sourcepub fn pending(&self) -> Result<Vec<IntentRow>>
pub fn pending(&self) -> Result<Vec<IntentRow>>
The rows this pass may send: due, oldest deadline first, one batch.
Not the whole queue — ClientStore::flush_order bounds what is due and
how many rows one pass takes, and a row still inside its backoff is asked
for again on the pass its deadline arrives.
pub fn next_delay(&self, attempt: u32) -> Duration
Sourcepub fn fail_local(&self, row: &IntentRow, reason: &str) -> Result<IntentResult>
pub fn fail_local(&self, row: &IntentRow, reason: &str) -> Result<IntentResult>
Count one pass in which this process could not act on a row at all.
A payload that no longer decodes will not decode on a later pass, and a
row left at its old deadline holds the head of the flush batch forever:
every pass spends a slot on a frame that can never be built, and behind a
batch cap that slot is one the queue’s oldest sendable row did not get.
Charging the pass retires the row at MAX_LOCAL_FAILURES the way a
refused row retires at attempts — exhausted, with the fault that names
the reason — and the backoff meanwhile takes it out of the due window, so
the head moves on the same pass.
A transport failure is not this path: the link being down says nothing
about the row, so IntentMachine::defer keeps its budget intact and the
reconnect flushes it (plan §6 line 289).