1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use Utc;
use ;
use crateAggregate;
/// Envelope around a domain event that bundles the payload with technical
/// metadata and business context.
///
/// In an event-sourced system the raw [`Aggregate::Event`] alone is rarely
/// enough — consumers also need to know which aggregate the event belongs
/// to, when it occurred, and what business request triggered it. The
/// envelope solves that by carrying three orthogonal concerns side by side:
///
/// - [`metadata`](Self::metadata) — technical facts about the event itself
/// (aggregate identity, occurrence timestamp).
/// - [`payload`](Self::payload) — the domain event variant produced by the
/// aggregate, expressing *what* happened.
/// - [`context`](Self::context) — propagation/tracing information linking
/// this event back to a correlation chain, an actor, etc.
///
/// `EventEnvelope` is what flows between the domain and persistence layers
/// (it round-trips through [`SerializedEvent`](crate::persist::SerializedEvent))
/// and is also the natural unit handed to event handlers.