Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Event Sourcing - History in the making
Search
Benjamin Dulau
February 19, 2015
Programming
240
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Event Sourcing - History in the making
Benjamin Dulau
February 19, 2015
Other Decks in Programming
See All in Programming
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
150
FreeBSDでZabbixを動かす
kenkino
0
310
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
210
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
250
JRuby: Past, Present, and Future
headius
0
120
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
4
2.7k
MVNOの申込からeSIM開通までをiOSアプリでつなぐ- 本人確認・MNP・通信事業者基盤をまたぐ実装
satotakeshi
0
440
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
220
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
190
そのリトライ、死んだコネクションを使い回していませんか ── GoのHTTPクライアントとHTTP/2を実プロダクト障害から学び直す
myus4a
0
150
Kiroで創り、AgentCoreで繋ぐ!AWSで実践する「AI-DLC」から「AIエージェント統合」までの最新地図
licux
4
700
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
0
1.5k
Featured
See All Featured
RailsConf 2023
tenderlove
30
1.5k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
510
Code Reviewing Like a Champion
maltzj
528
40k
Documentation Writing (for coders)
carmenintech
77
5.5k
Paper Plane
katiecoart
PRO
4
53k
Done Done
chrislema
186
16k
How to train your dragon (web standard)
notwaldorf
97
6.8k
Accessibility Awareness
sabderemane
1
210
Designing Powerful Visuals for Engaging Learning
tmiket
1
570
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
240
Transcript
Event Sourcing History in the making
Benjamin Dulau Entrepreneur anonymation.com Co-founder thebigbrainscompany.com Web architect @benjamindulau
Event Sourcing
❝ I want a list of all members that signed
in at least four times between 1st January and 15th January 2014… and … I want to compare this to the same period range but in 2013. ❞ Business guy
ID username last_login 1 ehamill 2007-01-22 03:04:39 2 lherman 2012-04-27
10:38:28 3 darien13 2010-06-16 21:43:06 4 olind 2012-01-02 04:31:21 … … … Current data
Event Sourcing resolves this issue.
RDBMS as the center of the architecture
State A Something important happened (delta) State B Time
State A Something important happened (delta) State B Dropped Stored
Dropped Working with current state Time
Lost data could have a massive value for the business.
ID CartId SKU Qty 1 1 ABC 5 2 1
DEF 1 3 1 IJK 10 Cart Cart lines ID CustomerId 1 1 2 1 3 1 1 0..*
In life, the only way to understand the present is
to look at the past.
If we know the events of the past, we can
reconstitute the present.
Event Sourcing
State A Something important happened (delta) State B Stored Reconstituted
Reconstituted Time Working with Event Sourcing
We express what happened in the past as a series
of Domain Events
happened in the past.
CustomerWithdrewCash
A Domain Event is a Message emitted by the Domain
Model to inform the system that something relevant happened.
class CustomerWithdrewCash implements DomainEvent { public $customerId; public $accountId; public
$amount; public $date; public function __construct($customerId, $accountId, $amount, $date) { $this->customerId = $customerId; $this->accountId = $accountId; $this->amount = $amount; $this->date = $date; } }
A message has no behavior and it is easy to
serialize.
Event Store
An append-only database storing a series of events organized in
event streams.
Bob’s account stream (Domain Model) CustomerWithdrewCash CustomerDepositedMoney CustomerWithdrewCash CustomerPaidWithHisCreditCard
JSON JSON JSON JSON Bob’s account stream (Database - Event
Store)
{ payload: { customerId: "123", accountId: "456", amount: 150, date:
"2005-08-15T15:52:01+00:00" }, eventType: "CustomerWithdrewCash" }
CustomerWithdrewCash CustomerDepositedMoney CustomerWithdrewCash CustomerPaidWithHisCreditCard Replay history Bob’s account current state
balance.
Reconstituting JSON JSON JSON JSON Fetch & unserialize Domain Event
Domain Event Domain Event Domain Event Domain Model Aggregate apply one-by-one Event stream Domain events object collection
No need for an ORM
Modelling freedom
No delete What’s done is done.
A delete is explicitly expressed as a domain event. It
is part of history.
Immutability = Infinite caching
Transactional by nature
Business Intelligence
Allows to ask almost any question to the data.
Projections
Derivative of the facts
Code that goes over a stream of events and produces
a transient state of it.
Domain Events UI View Models Statistics Models Search index Models
API Read models
class LatestMemberViewGenerator implements EventHandler { private $memberDAO; public function __construct(MemberDAO
$memberDAO) { $this->memberDAO = $memberDAO; } public function whenMemberHasSignedUp(MemberHasSignedUp $event) { $this->memberDAO->addToLatestMemberList(new LatestMemberItem( $event->memberId, $event->name, $event->username, $event->email, $event->date )); } }
Any structural representation of the data.
CQRS
Command Query Responsibility Segregation
None
Summary
Working with current state always involves valuable data loss.
Events in the domain should be explicitly expressed in the
domain model and in the ubiquitous language.
Being able to replay history is a major benefit both
technically and for the business.
Immutability is a bless.
A single model doing everything can’t be right and it
won’t scale.
Questions?