-
Notifications
You must be signed in to change notification settings - Fork 1
Event Shape and Streams
Paul Grimshaw edited this page Feb 28, 2025
·
4 revisions
In traditional Event Sourcing, each event is stored in a Stream, which usually represents the Aggregate. However in DCB Event Sourcing, the Aggregate is pretty much eliminated, and the streams are dynamic, governed by the event types and tags. In Sara's examples, she describes each event having a type and domain IDs. However, here we have given the domain IDs the name tags, but the idea is the same.
Each event has a type and a set of tags, as well as data:
const event: EsEvent = {
type: "courseWasRegistered",
tags: ["courseId=1234"],
data: {
courseID: "1234",
title: "My course title",
capacity: 10
}
}
When returned from an event-store, these are wrapped in an EventEnvelope:
//Note typically you will never instantiate an EsEventEnvelope as they are returned from the store
const eventEnvelope: EsEventEnvelope = {
sequencePosition: 1234,
timestamp: "2024-06-04T20:59:00Z",
event: {
type: "courseWasRegistered",
tags: ["courseId=1234"],
data: {
courseID: "1234",
title: "My course title",
capacity: 10
}
}
}