Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CQRS & Event Sourcing in OLX
Search
Łukasz Szymański
May 16, 2016
Programming
7
1.8k
CQRS & Event Sourcing in OLX
Łukasz Szymański
May 16, 2016
Tweet
Share
More Decks by Łukasz Szymański
See All by Łukasz Szymański
Chain reaction of scaling up
szymanskilukasz
1
120
GraphQL Without Hype
szymanskilukasz
0
250
PHP's Not Dead - PHP7 In Practice
szymanskilukasz
10
42k
Text Retrieval
szymanskilukasz
0
160
OLX pod maską [PL]
szymanskilukasz
2
660
Other Decks in Programming
See All in Programming
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
初めてDefinitelyTypedにPRを出した話
syumai
0
400
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
Realtime API 入門
riofujimon
0
150
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
910
Ethereum_.pdf
nekomatu
0
460
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
Amazon Qを使ってIaCを触ろう!
maruto
0
400
Quine, Polyglot, 良いコード
qnighy
4
640
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
610
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.7k
Featured
See All Featured
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
GitHub's CSS Performance
jonrohan
1030
460k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Fireside Chat
paigeccino
34
3k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
A designer walks into a library…
pauljervisheath
203
24k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
A Philosophy of Restraint
colly
203
16k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Transcript
CQRS Event Sourcing in OLX
CQRS
you can use a different model to update information than
the model you use to read information http://martinfowler.com/bliki/CQRS.html „
Command Query Responsibility Segregation
Command Query Responsibility Segregation
new AddCredits($userId, $amount); Command
Command new AddCredits($userId, $amount); Query new GetCredits($userId);
Event Sourcing
http://www.martinfowler.com/eaaDev/EventSourcing.html „ ensures that all changes to application state are
stored as a sequence of events
Not just can we query these events, we can also
use the event log to reconstruct past states http://www.martinfowler.com/eaaDev/EventSourcing.html „
Commad Event Model Event Storage Event Bus Command Handler Listeners
Read Storage Read Model Query
Commad Event Model Event Storage Event Bus Command Handler Listeners
Read Storage Read Model Query Critical section - use transaction
Commad Event Model Event Storage Event Bus Command Handler Listeners
Read Storage Read Model Query Critical section - use transaction Treat like temporary cache
That’s all
E-Wallet Credits; Invoices; Refunds
Wallet Credits Bonus Credits Refund Credits EXPIRE: X DAYS EXPIRE:
X DAYS EXPIRE: X DAYS INVOICE: YES/NO INVOICE: YES/NO INVOICE: YES/NO
Wallet Credits Bonus Credits Refund Credits EXPIRE: NEVER EXPIRE: 90
DAYS EXPIRE: 90 DAYS INVOICE: YES INVOICE: NO INVOICE: YES
Opis walleta w Polsce specyfikacja komenty enventy Commands
Add Wallet Credits Add Bonus Credits Add Refund Credits
Sub Wallet Credits Sub Bonus Credits Sub Refund Credits SubCredits
Opis walleta w Polsce specyfikacja komenty enventy Events
Wallet CreditsWasAdded Bonus CreditsWasAdded Refund CreditsWasAdded
Wallet CreditsWasSubtracted Bonus CreditsWasSubtracted Refund CreditsWasSubtracted
specyfikacja komenty enventy 7 commands 6 events
specyfikacja komenty enventy What about other stuff?
Commad Event Model Event Storage Event Bus Command Handler Listeners
Read Storage Read Model Query ?
Broadway komponenty Broadway https://github.com/qandidate-labs/broadway
Auditing log whether commands were successful or not
CommandHandling Provides the interface and a CommandHandler base class for
handling events
Domain domain abstractions of the Broadway framework including the aggregate
root, domain messages and domain events.
EventDispatcher The component provides an event dispatcher interface and a
simple implementation
EventHandling provides interfaces for an event bus and event listeners,
but also an implementation of a simple event bus and an event bus that will record published events
EventSourcing Provides base classes for event sourced aggregate roots and
entities, an event sourced repository implementation and testing helpers.
EventStore implementation based on doctrine/dbal to store events in a
relational database and an in-memory implementation that is useful for using in tests
ReadModel provides storage for your read models, a projector implementation
to create read models from event streams and testing helpers.
Repository Component providing an abstraction of the storage of aggregates.
Serializers provides a simple serializer interface and a serializer implementation
based on "handwritten" serializers
Commad Event Model Event Storage Event Bus Command Handler Listeners
Read Storage Read Model Query Broadway
Adding Wallet Credits
None
None
Credits Query
None
None
Lessons Learned
Small Steps Don’t try to CQRS/EventSource everything
Keep It Simple Avoid names like BonusCreditsWasSubtractedBecauseAdminHitSubtractBonusCr editsInAdminPanelEvent
Event Storming is not that easy as it sounds
It’s not RDBM Remember about analysts
Code changes Events handle changes to data, what about changes
to code?
Synchronize Remember about synchronizing read layer - especially after fail
Commad Event Model Event Storage Event Bus Command Handler Listeners
Read Storage Read Model Query Critical section - use transaction
Performance is not an issue - for this case
Timezone Agnostic Implement your own EventStore if you want timezone
aware records
Our Team
Paid Features
Next challenge Open source Paid Features libraries with Hexagonal Architecture
in mind
Team Lead PHP Dev Junior PHP Dev You ?
Łukasz Szymański Development Team Lead at @szymanskilukasz http://szymanskilukasz.github.io/ https://www.linkedin.com/in/szymanskilukasz https://twitter.com/szymanskilukasz