Struct ReplicatedEvent
#[non_exhaustive]pub struct ReplicatedEvent {
pub id: EventId,
pub recorded_at: RecordedAt,
pub event: Event,
}Expand description
An event on the wire: an Event plus the two facts its origin store
assigned to it.
This is the unit both SyncPeer and
IngestStore move. It carries no
SequencePosition of its own beyond the one inside EventId, because
the receiver assigns that and the sender’s copy would be actively misleading.
It is SequencedEvent field for field,
less the local position — and that omission is SY-19, not an economy.
The payload inside event is never decoded here. That is the whole payoff of
keeping happenstance-core free of serde in its default features: a peer
forwards bytes it does not understand and cannot corrupt by re-encoding.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: EventIdWho minted this event, and where it landed in their log.
recorded_at: RecordedAtWhen the origin store accepted it.
event: EventThe event itself, payload opaque.
Implementations§
§impl ReplicatedEvent
impl ReplicatedEvent
pub const fn new(id: EventId, recorded_at: RecordedAt, event: Event) -> Self
pub const fn new(id: EventId, recorded_at: RecordedAt, event: Event) -> Self
Assembles a wire event from an origin store’s three facts.
Examples found in repository?
353 pub async fn judge_again(&self) -> Result<usize, StoryError> {
354 let held = self
355 .central
356 .log(Place::Central)
357 .await?
358 .into_iter()
359 .map(|event| ReplicatedEvent::new(event.id, event.recorded_at, event.event))
360 .collect();
361 let answered = self
362 .rule
363 .compensation(&EventGroup::new(None, held), &[])
364 .await
365 .map_err(StoryError::Adjudicate)?;
366 Ok(answered.len())
367 }pub fn payload_len(&self) -> usize
pub fn payload_len(&self) -> usize
Bytes this event occupies in a peer’s size budget.
Only the payload and metadata are counted; the type and tags are already
bounded at 255 bytes each by the contract, and no engine struggles with
those. See PeerLimits.