Introductory-level talk about event sourcing and command query responsibility segregation (CQRS), held at the "Softwerkskammer Lübeck" Meetup (https://www.meetup.com/Softwerkskammer-Luebeck/events/gjsxslyxlbdb/) in August 2018. Code examples that were shown live can be found at https://github.com/danbim/ledger-example and https://github.com/danbim/pwa-scoring.
3. – Greg Young
“When you start modelling events, it forces
you to think about the behaviour of the
system. As opposed to thinking about the
structure of a system.”
5. Event Sourcing
• Events represent facts of information
• Facts are immutable
• Facts accrue - knowledge can only grow
• Events/Facts can be not be retracted
(once accepted)
• Events/Facts can not be deleted
(once accepted)
• Events/Facts (new) can invalidate existing facts
Source: https://www.infoq.com/presentations/systems-event-driven
6. Event Log
• Stores facts (events)
• Stores changes to the
system, not the
current state
• Immutable, append-only
• Allows for audit, traceability and time travel!
15. Impressions from Contests
• https://vimeo.com/192004764
(Aloha Classic 2017 03:00)
• https://vimeo.com/87398773
(Alex Mussolini @ Cabezo 01:30)
• https://livestream.com/accounts/9351246/
events/8290781/videos/177769199
(Pozo Single Elimination Day 2)
04:09:00 h / 05:43:00 h
16. Wave Contest Rules
• A contest is split into single and double
elimination
• A single elimination is (almost) like the knockout
stage in football
• A match between two riders is called “heat”
18. Wave Contest Rules
• Riders ride 1 vs. 1, oftentimes two matches are
run in parallel
• Riders get points for wave rides and points for
jumps
• The rider with higher total points proceeds to the
next round
22. Command Query
Responsibility Segregation
• Separate responsibility between commands (write
requests) and queries (read requests)
• Separation between “write model” and “read
model”
• Read models can e.g. use a different data model /
a different data store
• E.g. a “NoSQL” denormalized data store
optimized for full-text search
23. (Aggregate) Actors
Implementation Overview
Domain
Model
Event Log
REST API
Heat Events Stream
(Server Sent Events API)
CLI
(for judges)
Browser
(for viewers)
(ro)
(rw)
Write Model
Heat State Stream
(Server Sent Events API)
Browser
(for viewers)
Read (View) Model(s)
https://github.com/danbim/pwa-scoring
26. Event Sourcing - Challenges
• Serialization: backwards compatibility
• need to deserialize old events
• challenge to support schema evolution
• https://doc.akka.io/docs/akka/2.5/persistence-
schema-evolution.html
27. Event Sourcing - Challenges
• Replay duration —> Snapshots
• Aggregate consistency boundaries (guarantee
single writer per aggregate) —> e.g. Akka
cluster sharding
• DSGVO - the European right to be forgotten -
how to delete data from an immutable store?