pub struct EventId { /* private fields */ }Expand description
A store-assigned event identity: which store first accepted the event, and at what position it did so.
Stable under replication. A store that accepts an event through ingest
preserves the EventId it arrived with, and mints one only for events
appended to it locally. That is what makes deduplication possible without
anybody parsing a payload.
§Why the fields are private
The two halves are one fact, not two, and a transparent pair would let the
compiler accept EventId { store: theirs, position: mine } without a word —
exactly the value this type exists to make deliberate. Both accessors return
by value; both halves are Copy.
This is not in tension with SequencedEvent’s
public fields: those are four independent facts a reader wants by name.
Implementations§
Source§impl EventId
impl EventId
Sourcepub const fn new(store: StoreId, position: SequencePosition) -> Self
pub const fn new(store: StoreId, position: SequencePosition) -> Self
Pairs the minting store with the position it assigned.
Sourcepub const fn store(self) -> StoreId
pub const fn store(self) -> StoreId
The incarnation that first accepted this event.
Examples found in repository?
186fn read_back<W: Write>(converged: &Converged, out: &mut W) -> Result<(), StoryError> {
187 writeln!(out, "\n== every handle dropped; reading the files back ==")?;
188 for (at, replica) in converged.replicas() {
189 if replica
190 .refunds
191 .iter()
192 .any(|id| id.store() != converged.central.store)
193 {
194 return Err(StoryError::Contradicted {
195 claim: "central wrote every refund (SY-7)",
196 });
197 }
198 let refunds = u32::try_from(replica.refunds.len()).unwrap_or(u32::MAX);
199 writeln!(
200 out,
201 " {at:<8} {} events, {}, written by central",
202 replica.ids.len(),
203 plural(refunds, "refund", "refunds")
204 )?;
205 }
206 if !converged.agrees() {
207 return Err(StoryError::Contradicted {
208 claim: "the three files agree",
209 });
210 }
211 writeln!(
212 out,
213 " the three logs hold the same {} events; the three read models are identical",
214 converged.central.ids.len()
215 )?;
216 Ok(())
217}Sourcepub const fn position(self) -> SequencePosition
pub const fn position(self) -> SequencePosition
The position the minting store assigned.
Authorship order, not arrival order. For a locally appended event
this equals the enclosing SequencedEvent’s
position; for an event that arrived through ingest it does not, and the
two carry different information — this one orders the event in its origin
store, the other orders it here.
Trait Implementations§
impl Copy for EventId
Source§impl<'de> Deserialize<'de> for EventId
Available on crate feature serde only.
impl<'de> Deserialize<'de> for EventId
serde only.