pub struct OutboxRecord {
pub id: Uuid,
pub event_type: String,
pub aggregate_type: String,
pub aggregate_id: String,
pub company_id: Uuid,
pub payload: Value,
pub occurred_at: DateTime<Utc>,
pub correlation_id: Option<String>,
pub causation_id: Option<String>,
pub version: i32,
}Expand description
A serialized domain event staged in the outbox and carried to consumers.
The id is the single end-to-end dedup key (the backbone-messaging envelope id): the producer
stages it, the relay carries it, the consumer dedups on it via crate::inbox::once.
Fields§
§id: UuidThe event id — the dedup key. Take it from the messaging EventEnvelope::id.
event_type: StringThe event type name, e.g. "PaymentSettled".
aggregate_type: StringThe aggregate type the event belongs to, e.g. "Payment".
aggregate_id: StringThe aggregate id (as a string — aggregates key on uuid, code, or number).
company_id: UuidThe owning tenant — the outbox_events table is fenced by this (ADR-0011). Every staged event carries the company it belongs to so the RLS policy can isolate tenant event streams.
payload: ValueThe serialized domain event payload.
occurred_at: DateTime<Utc>When the event occurred in the domain.
correlation_id: Option<String>Correlation id for tracing a business flow across events.
causation_id: Option<String>Causation id (the parent event that caused this one).
version: i32Event schema version (see extension-contract.md §4).
Implementations§
Source§impl OutboxRecord
impl OutboxRecord
Sourcepub fn new(
event_type: impl Into<String>,
aggregate_type: impl Into<String>,
aggregate_id: impl Into<String>,
company_id: Uuid,
payload: Value,
occurred_at: DateTime<Utc>,
) -> Self
pub fn new( event_type: impl Into<String>, aggregate_type: impl Into<String>, aggregate_id: impl Into<String>, company_id: Uuid, payload: Value, occurred_at: DateTime<Utc>, ) -> Self
Build a record with a fresh id, no correlation/causation, version 1, occurred_at = now.
(now is passed in so callers stay deterministic under test.) company_id is the owning
tenant — required, since the outbox_events table is fenced by it (ADR-0011).
Sourcepub fn with_id(self, id: Uuid) -> Self
pub fn with_id(self, id: Uuid) -> Self
Set the event id explicitly (e.g. reuse the messaging envelope id).
Sourcepub fn with_correlation_id(self, id: impl Into<String>) -> Self
pub fn with_correlation_id(self, id: impl Into<String>) -> Self
Set the correlation id.
Trait Implementations§
Source§impl Clone for OutboxRecord
impl Clone for OutboxRecord
Source§impl Debug for OutboxRecord
impl Debug for OutboxRecord
Source§impl<'de> Deserialize<'de> for OutboxRecord
impl<'de> Deserialize<'de> for OutboxRecord
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for OutboxRecord
impl PartialEq for OutboxRecord
Source§impl Serialize for OutboxRecord
impl Serialize for OutboxRecord
impl StructuralPartialEq for OutboxRecord
Auto Trait Implementations§
impl Freeze for OutboxRecord
impl RefUnwindSafe for OutboxRecord
impl Send for OutboxRecord
impl Sync for OutboxRecord
impl Unpin for OutboxRecord
impl UnsafeUnpin for OutboxRecord
impl UnwindSafe for OutboxRecord
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more