Skip to main content

photon_backend/models/
event.rs

1//! Event model and envelope.
2
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5
6/// Published event with payload and metadata.
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct Event {
9    /// Unique event ID (UUID).
10    pub event_id: String,
11    /// Topic name.
12    pub topic_name: String,
13    /// Key value if keyed topic.
14    pub topic_key: Option<String>,
15    /// Sequence number per topic/key.
16    pub seq: i64,
17    /// Captured identity (actor JSON).
18    pub actor_json: serde_json::Value,
19    /// Serialized payload.
20    pub payload_json: serde_json::Value,
21    /// When the event was published.
22    pub created_at: DateTime<Utc>,
23}
24
25/// Event envelope with decoded payload.
26#[derive(Debug, Clone)]
27pub struct Envelope<T> {
28    /// The raw event metadata.
29    pub event: Event,
30    /// Decoded payload.
31    pub payload: T,
32}