#[non_exhaustive]pub struct EventEnvelope {
pub id: Uuid,
pub event_type: String,
pub aggregate_type: String,
pub aggregate_id: Uuid,
pub schema_version: u16,
pub occurred_at: DateTime<Utc>,
pub payload: Value,
pub headers: BTreeMap<String, String>,
}Expand description
One event as it travels: the outbox row, a delivery, a Kafka message. Its id stays the same
across redeliveries, so a handler deduplicates on it.
#[non_exhaustive]: built with EventEnvelope::new (a new event) or
EventEnvelope::from_parts (one read back from a store), so a later field breaks no one.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: Uuid§event_type: String§aggregate_type: String§aggregate_id: Uuid§schema_version: u16§occurred_at: DateTime<Utc>§payload: Value§headers: BTreeMap<String, String>Context that is not the event’s: correlation_id, later tenant_id.
Implementations§
Source§impl EventEnvelope
impl EventEnvelope
Sourcepub fn new(event: &impl DomainEvent) -> Self
pub fn new(event: &impl DomainEvent) -> Self
A new event: the id is a UUID v7, so ids sort by the time they were made.
pub fn from_parts(parts: EnvelopeParts) -> Self
pub fn with_header( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Sourcepub fn decode<T: DeserializeOwned>(&self) -> Result<T, DecodeError>
pub fn decode<T: DeserializeOwned>(&self) -> Result<T, DecodeError>
The payload as the snapshot type the consumer subscribed to.
Trait Implementations§
Source§impl Clone for EventEnvelope
impl Clone for EventEnvelope
Source§impl Debug for EventEnvelope
impl Debug for EventEnvelope
Source§impl PartialEq for EventEnvelope
impl PartialEq for EventEnvelope
impl StructuralPartialEq for EventEnvelope
Auto Trait Implementations§
impl Freeze for EventEnvelope
impl RefUnwindSafe for EventEnvelope
impl Send for EventEnvelope
impl Sync for EventEnvelope
impl Unpin for EventEnvelope
impl UnsafeUnpin for EventEnvelope
impl UnwindSafe for EventEnvelope
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more