pub struct SubscriptionEvent {
pub event_id: String,
pub entity_type: String,
pub entity_id: String,
pub operation: SubscriptionOperation,
pub timestamp: DateTime<Utc>,
pub sequence_number: u64,
pub data: Value,
pub old_data: Option<Value>,
pub tenant_id: Option<String>,
pub change_spine: Option<ChangeSpineEnvelope>,
}Expand description
An event from the database that may trigger subscriptions.
This is the internal event format, captured from LISTEN/NOTIFY or CDC.
Fields§
§event_id: StringUnique event identifier.
entity_type: StringEntity type name (e.g., “Order”, “User”).
entity_id: StringEntity primary key.
operation: SubscriptionOperationDatabase operation that created this event.
timestamp: DateTime<Utc>Event timestamp (from database).
sequence_number: u64Monotonic sequence number for ordering.
data: ValueEvent payload data (the row data as JSON).
old_data: Option<Value>Optional old data (for UPDATE operations).
tenant_id: Option<String>Tenant identifier for multi-tenant isolation (from fk_customer_org).
change_spine: Option<ChangeSpineEnvelope>Change-Spine envelope metadata for client delivery (#425). Carried for the
subscription next payload’s extensions.changeSpine; not used for
server-side filtering.
Implementations§
Source§impl SubscriptionEvent
impl SubscriptionEvent
Sourcepub fn new(
entity_type: impl Into<String>,
entity_id: impl Into<String>,
operation: SubscriptionOperation,
data: Value,
) -> Self
pub fn new( entity_type: impl Into<String>, entity_id: impl Into<String>, operation: SubscriptionOperation, data: Value, ) -> Self
Create a new subscription event.
Sourcepub fn with_old_data(self, old_data: Value) -> Self
pub fn with_old_data(self, old_data: Value) -> Self
Add old data for UPDATE operations.
Sourcepub const fn with_sequence(self, seq: u64) -> Self
pub const fn with_sequence(self, seq: u64) -> Self
Set the sequence number.
Sourcepub fn with_tenant_id(self, tenant_id: impl Into<String>) -> Self
pub fn with_tenant_id(self, tenant_id: impl Into<String>) -> Self
Set the tenant identifier for multi-tenant filtering.
Sourcepub fn with_change_spine(self, envelope: ChangeSpineEnvelope) -> Self
pub fn with_change_spine(self, envelope: ChangeSpineEnvelope) -> Self
Attach the Change-Spine envelope for client delivery (#425).
Trait Implementations§
Source§impl Clone for SubscriptionEvent
impl Clone for SubscriptionEvent
Source§fn clone(&self) -> SubscriptionEvent
fn clone(&self) -> SubscriptionEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more