Event Sourcing THE BEST, UBIQUITOUS PATTERN YOU’VE NEVER HEARD OF @blimpyacht
Event SourcingTHE BEST, UBIQUITOUS PATTERN
YOU’VE NEVER HEARD OF
@blimpyacht
5
User: ABalance: 427
User: BBalance: 550
User: ABalance: 427
User: BBalance: 550
User: ABalance: 427
User: BBalance: 550
+5-5
Event Sourcing
State
+4-2+5+7-4+9-3-6+2+1+1-5 t(12) = 9
Event Sourcing
+4-2+5+7-4+9-3-6+2+1+1-5
t(5) = 10
Event Sourcing
+4-2+5+7-4+9-3-6+2+1+1-5
t(9) = 12
Event Sourcing
+4-2+5+7-4+9-3-6+2+1+1-5
Event Sourcing
a = f ’(x)
+4-2+5+7-4+9-3-6+2+1+1-5
Event Sourcing
+5-4+5
Res Gestae Divi Augusti
2ndaryPrimary
2ndaryPrimary
2ndaryPrimary
+4-2+5+7-4+9-3-6+2+1+1-5
Event Sourcing
+4-2+5+7-4+9-3-6+2+1+1-5
t(4) = 14
Event Sourcing
t(8) = 10
t(12) = 9
+4-2+5+7-4+9-3-6+2+1+1-5
t(4) = 14
Event Sourcing
t(8) = 10
t(12) = 9
t’(4) = -2
t’(8) = -17
t’(12) = -22
{ _id: {
ts: 1213084687000, taxi: "abboip" }, loc: {
geometry: [ -122.39488, 37.75134
] }, fare: 0, ts: ISODate("2008-06-10T07:58:07Z")}
{ _id: ObjectId("56a4215a46778b69e08ff8ff"), taxi: "abboip", start: ISODate("2008-05-17T14:51:10Z"), route: { type: "LineString", coordinates: [ [ -122.39724, 37.74977 ], [ -122.40619, 37.74896 ], [ -122.41335, 37.74831 ], [ -122.414, 37.75157 ], [ -122.41438, 37.75552 ]
] }, end: ISODate("2008-05-17T14:55:58Z")}
Data Modeling Domain EventsDomain Objects
Accounts Payable
Accounts Payable
Accounts Receivable
Accounts Payable
Accounts Receivable
Journal
Accounts Payable
Accounts Receivable
Journal
Ledger
Command QueryResponsibility
Segregation
CQRS
CRUD vs. CQRS
CRUD
CRUD vs. CQRS
WRITE
READ
CRUD vs. CQRS
CRUD equals CQRS
WRITE
READ
READ
CRUD vs. CQRS
WRITE
READ
Variant Read Models: VIEWS
READREADREADREAD
WRITE
READ
Primary
READ
CRUD vs. CQRS
CRUD vs. CQRS
WRITE
READ
READ
Primary
2ndary
2ndary
Where it Gets Tricky
CRUD vs. CQRS
WRITE
READ
READ
Primary
2ndary
2ndary
CRUD vs. CQRS
WRITE
READ
READ
Primary
2ndary
2ndary
Consistent Replay+4-2+5+7-4+9-3-6+2+1+1-5
t(5) = 10 Exchange Rate Server
10 / 0.88 = 8.82€
Consistent Replay+4-2+5+7-4+9-3-6+2+1+1-5
t(5) = 10 Exchange Rate Server
10 / 0.87 = 8.70€
+4-2+5+7-4
+9-3-6+2+1+1-5
0.88 Exchange Rate Server
Consistent Replay
Where it Gets Trickier Still
External Updates+4-2+5+7-4+9-3-6+2+1+1-5
Notification
Subscriber
External Updates+4-2+5+7-4+9-3-6+2+1+1-5
Notification
Subscriber
Gaining Insight