Event sourcing using Laravel
Who am I?
Damiano Petrungaro
Italy
source: www.vidiani.com
Tivoli (RM)
source: www.livitaly.com
Tivoli (RM)
source: www.romaest.org
Tivoli (RM)
source: www.tivolitouring.com
Tivoli (RM)
source: www.confinelive.it
Tivoli (RM)
source: www.greenparkmadama.it
Me everyday:
Event sourcing
Capture all changes to an application state as a sequence of events.
CQRS
It's a pattern that I first heard described by Greg Young.
At its heart is the notion that you can use a different model to update information than the model you use to read information.
command query responsibility segregation
Command
vs
Query
Events
It's an immutable object used to represent something important that occurred in the domain.
Events
let's code
Domain model
It's a mutable object with an identity, it can be represented in different ways.
It's comparable to other entities by its ID.
Aggregate root
A DDD aggregate is a cluster of domain objects that can be treated as a single unit.
An example may be an order and its line-items, these will be separate objects, but it's useful to treat the order (together with its line items) as a single aggregate.
aka: write model
Value Object
It's an immutable object representing a value in a domain.
It's comparable to other value objects by its own values.
Domain Model
let's code
Command
It's a write operation!
Command
let's code
Extra: Repository
It's an abstraction layer to provide access to all the entities and the value objects related to an aggregate.
Extra: Repository
let's code
Read Model
A read model is a model specialized for reads, that is, queries.
It takes events produced by the domain and uses them to build and maintain a model that is suitable for answering the client's queries.
It can draw on events from different aggregates and even different types of aggregate.
Projection
Projection is a specialized representation of the state derivated from of our system
Read Model
&
Projector
let's code
Discussions & Questions
101
Let's do some homework
Event sourcing using Laravel
By Damiano Petrungaro
Event sourcing using Laravel
- 824