47
hello! @pieterkoornho f sneakycode.net

Event Sourcing and Combating Accidental Complexity

Embed Size (px)

Citation preview

Page 1: Event Sourcing and Combating Accidental Complexity

hello!

@pieterkoornhof

sneakycode.net

Page 2: Event Sourcing and Combating Accidental Complexity

Assume Complex Problems

Page 3: Event Sourcing and Combating Accidental Complexity

accidental complexity

Page 4: Event Sourcing and Combating Accidental Complexity

3 Choices

Page 5: Event Sourcing and Combating Accidental Complexity

#1

Page 6: Event Sourcing and Combating Accidental Complexity

sql#1

orm

logic

Page 7: Event Sourcing and Combating Accidental Complexity

sql#1

orm

logic

dto+

serviceddd

entities

Page 8: Event Sourcing and Combating Accidental Complexity

sql#1

orm

logic

Page 9: Event Sourcing and Combating Accidental Complexity

sql#1

orm

logic

views

Page 10: Event Sourcing and Combating Accidental Complexity

sql#1

views

Page 11: Event Sourcing and Combating Accidental Complexity

sql#1

Page 12: Event Sourcing and Combating Accidental Complexity

#1 Confused Models

Page 13: Event Sourcing and Combating Accidental Complexity

#2

Page 14: Event Sourcing and Combating Accidental Complexity

Full Text

Searching

Related

ItemsData Blobs

Reporting

Fancy Databas

e

#2

Page 15: Event Sourcing and Combating Accidental Complexity

Graph

Relational

Fancy Databas

e

#2

Search Index

Document

Page 16: Event Sourcing and Combating Accidental Complexity

App

#2

Graph

Relational

Search Index

Document

Page 17: Event Sourcing and Combating Accidental Complexity

#2 Wrong Models( Sucky Database )

Page 18: Event Sourcing and Combating Accidental Complexity

#3

Page 19: Event Sourcing and Combating Accidental Complexity

#3

Cart

Product

Customer

*

Page 20: Event Sourcing and Combating Accidental Complexity

Peets Cart

#3

Page 21: Event Sourcing and Combating Accidental Complexity

++++

++++ + -

Peets Cart

#3

Page 22: Event Sourcing and Combating Accidental Complexity

Cart

Product

Customer

*1. Added Apple

2. Added Apple

3. Added Rocket

4. Added Camera

5. Removed Rocket

6. Added Bike

7. Paid

#3

Page 23: Event Sourcing and Combating Accidental Complexity

Cart

Product

Customer

*

Removed

Item*

#3

Page 24: Event Sourcing and Combating Accidental Complexity

1. Added Apple

2. Added Apple

3. Added Rocket

4. Added Camera

5. Removed Rocket

6. Added Bike

7. Paid

Cart

Product

Customer

*

Removed

Item

*

#3

Page 25: Event Sourcing and Combating Accidental Complexity

#3 Data Loss

Page 26: Event Sourcing and Combating Accidental Complexity

#1 Confused Models #2 Wrong Models #3 Data Loss

accidental complexity

Page 27: Event Sourcing and Combating Accidental Complexity

data Graph

Relational

Fancy Database

Search

Index

Document

#1 Confused Models #2 Wrong Models #3 Data Loss

1. Added Apple2. Added Apple3. Added Rocket4. Added Camera5. Removed Rocket6. Added Bike7. Paid

CQRS Polyglot Data Event Sourcing

Page 28: Event Sourcing and Combating Accidental Complexity

Event Sourcing

Page 29: Event Sourcing and Combating Accidental Complexity

event store

Stores EventsremovedFromCart { cartId: 2134-DSF3-SDFW, item : Rocket, quanity: 1}

1. Added Apple

2. Added Apple

3. Added Rocket

4. Added Camera

5. Removed Rocket

6. Added Bike

7. Paid

Page 30: Event Sourcing and Combating Accidental Complexity

event store

Append OnlyImmutable

No Updates

No Deletes

Page 31: Event Sourcing and Combating Accidental Complexity

I want to Pay

Page 32: Event Sourcing and Combating Accidental Complexity

Command

(write)

App

pay { cartId: 2134-DSF3-SDFW, discount: 31%, cardDetails: Visa}

Page 33: Event Sourcing and Combating Accidental Complexity

Command

(write)

App

event store f(events) => state

f(state, command) => event(s)

1. Added Apple2. Added Apple3. Added Rocket4. Added Camera5. Removed

Rocket6. Added Bike 7, Paid

Cart

Product

Customer

*

Page 34: Event Sourcing and Combating Accidental Complexity

Command

(write) read

App

event store

sql

neo4j

f(events) => viewState

Page 35: Event Sourcing and Combating Accidental Complexity

command eventLogic View

Page 36: Event Sourcing and Combating Accidental Complexity

command eventLogic View

store

Just Messages

No Data Loss!

Page 37: Event Sourcing and Combating Accidental Complexity

command eventLogic View

Things Happend

Replay!

Page 38: Event Sourcing and Combating Accidental Complexity

command eventLogic View

Scale!

Page 39: Event Sourcing and Combating Accidental Complexity

command eventLogic View

app.Handle( Command )

store.Load<T>( Id )

store.Save( T )

Minimal Boilerplate!

Page 40: Event Sourcing and Combating Accidental Complexity

command eventLogic View

input

output

Testing!events, command =>

event(s)

Page 41: Event Sourcing and Combating Accidental Complexity

command eventLogic View

jake

sas

Workload!

rob

Page 42: Event Sourcing and Combating Accidental Complexity

CharacteristicsMultiple Databases

Operational Complexity

Eventual Consistency

Page 43: Event Sourcing and Combating Accidental Complexity

3 Choices

Page 44: Event Sourcing and Combating Accidental Complexity

geteventstore.com

Page 45: Event Sourcing and Combating Accidental Complexity

github.com/SneakyPeet/EasyEventSourcing

Page 46: Event Sourcing and Combating Accidental Complexity

thanx!

@pieterkoornhof

sneakycode.net

Page 47: Event Sourcing and Combating Accidental Complexity

CreditsSpecial thanks to all the people who made and released these awesome resources for free:✘ Presentation template by SlidesCarnival✘ Photographs by Unsplash