52
Event Sourcing THE BEST UBIQUITOUS PATTERN YOU’VE NEVER HEARD OF @blimpyacht

Event sourcing

Embed Size (px)

Citation preview

Page 1: Event sourcing

Event SourcingTHE BEST UBIQUITOUS

PATTERN YOU’VE NEVER HEARD OF

@blimpyacht

Page 2: Event sourcing
Page 3: Event sourcing

User: ABalance: 427

User: BBalance: 550

Page 4: Event sourcing

User: ABalance: 427

User: BBalance: 550

Page 5: Event sourcing

User: ABalance: 427

User: BBalance: 550

+5-5

Page 6: Event sourcing

Event Sourcing

Page 7: Event sourcing

Event Sourcing

http://www.avanscoperta.it/en/training/cqrs-event-sourcing-and-applying-domain-driven-design/

Page 8: Event sourcing

https://media.licdn.com/media/p/5/005/09f/2d8/3c9f5a5.jpg

Event Sourcing

Page 9: Event sourcing

Event Sourcing

Command Query Responsibility Segregation(CQRS)

Page 10: Event sourcing

+4-2+5+7-4+9-3-6+2+1+1-5 t(12) = 9

Event Sourcing

Page 11: Event sourcing

+4-2+5+7-4+9-3-6+2+1+1-5

t(5) = 10

Event Sourcing

Page 12: Event sourcing

+4-2+5+7-4+9-3-6+2+1+1-5

t(9) = 12

Event Sourcing

Page 13: Event sourcing

+4-2+5+7-4+9-3-6+2+1+1-5

Event Sourcing

f ’(x) = A

Page 14: Event sourcing

+4-2+5+7-4+9-3-6+2+1+1-5

Event Sourcing

+5-4+5

Page 15: Event sourcing

Res Gestae Divi Augusti

Page 16: Event sourcing
Page 17: Event sourcing
Page 18: Event sourcing
Page 19: Event sourcing

2ndaryPrimary

Page 20: Event sourcing

2ndaryPrimary

Page 21: Event sourcing

2ndaryPrimary

Page 22: Event sourcing

+4-2+5+7-4+9-3-6+2+1+1-5

Event Sourcing

Page 23: 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

Page 24: Event sourcing
Page 25: Event sourcing

Journal

Page 26: Event sourcing

Journal

Ledger

Page 27: Event sourcing

Accounts Payable

Journal

Ledger

Page 28: Event sourcing

Accounts Payable Accounts Receivable

Journal

Ledger

Page 29: Event sourcing

Command QueryResponsibility Segregation

Page 30: Event sourcing

CQRS

Page 31: Event sourcing

CRUD vs. CQRS

CRUD

Page 32: Event sourcing

CRUD vs. CQRS

WRITE

READ

Page 33: Event sourcing

WRITE

READ

Primary

READ

CRUD vs. CQRS

Page 34: Event sourcing

WRITE Primar

y

READ

Variant Read Models: VIEWS

READREADREADREAD

Page 35: Event sourcing

WRITE

READ

Primary

READ

CRUD vs. CQRS

Page 36: Event sourcing

CRUD vs. CQRS2ndar

y

WRITE

READ 2ndary

Primary

READ

Page 37: Event sourcing

CRUD vs. CQRS2ndar

y

WRITE

READ 2ndary

Primary

READ

Page 38: Event sourcing

Where it Gets Tricky

Page 39: Event sourcing

CRUD vs. CQRS2ndar

y

WRITE

READ 2ndary

Primary

READ

Page 40: Event sourcing

CRUD vs. CQRS2ndar

y

2ndary

Primary

WRITE

READ

READ

Page 41: Event sourcing

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€

Page 42: Event sourcing

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€

Page 43: Event sourcing

+4-2+5+7-4+9-3-6+2+1+1-5

0.88 Exchange Rate Server

Consistent Replay

Page 44: Event sourcing

Bounded Contextapplicability of the modelinternally consistent UNIFICATION

Page 45: Event sourcing

Where it Gets More Tricky

Page 46: Event sourcing

External Updates+4-2+5+7-4+9-3-6+2+1+1-5

Notification

Subscriber

Page 47: Event sourcing
Page 48: Event sourcing

http://www.webstaurantstore.com/images/products/extra_large/68717/654170.jpg

Page 49: Event sourcing

External Updates+4-2+5+7-4+9-3-6+2+1+1-5

Notification

SubscriberKafka

Page 50: Event sourcing

THANKS!{ Name: ‘Bryan Reinero’,

Title: ‘Developer Advocate’,Twitter: ‘@blimpyacht’,

Email: ‘[email protected]’ }

Page 51: Event sourcing

{"_id" : ObjectId("565f1dd8d4c6d9a90a9a16ce"),"country" : "USA","crew" : "Ed White","vehicle" : "Gemini IV","date" : "6/3/65","duration" : "0:36","purpose" : "First U.S. EVA. Used HHMU and took photos,

"minutes" : 36}{

"_id" : ObjectId("565f1dd8d4c6d9a90a9a16cf"),"country" : "USA","crew" : "Eugene Cernan","vehicle" : "Gemini IX-A","date" : "6/5/66","duration" : "2:07","purpose" : "Inadequate restraints stiff 25ft umbilical and high workloads….,"minutes" : 127

}{

"_id" : ObjectId("565f1dd8d4c6d9a90a9a16d0"),"country" : "USA","crew" : "Mike Collins","vehicle" : "Gemini X","date" : "7/19/66","duration" : "0:50","purpose" : "Standup EVA. UV photos of stars. Ended by eye”,

"minutes" : 50}

Page 52: Event sourcing

db.EVA.aggregate([ { "$match": { "crew" : /David Scott/ } }, { "$project": {

_id: 0, name: { $literal: "David Scott" }, minutes: 1, }

}, { "$group": { _id: "$name", total: { $sum: "$minutes" } } }] );{ "_id" : "David Scott", "total" : 1200 }