Notes taken from the Event Sourcery Youtaube channel.
What is event sourcing?
Event sourcing is the practice of building application state from only domain events.
Every interaction with an object triggers an event. Each event contain individual information from the object state.
WorkFlow
- Check business rules (called Invariants)
- Event is raised
- Event is applied
- Update object state accordingly
Persistance (Event Store)
The events information is persisted. Not the object representation per se. All the events state form the whole object state.
Benefits
- All the object instance history is persisted. No data is overwritten (Immutable). (No update SQL statements).
- Data can be queried on a give time range. (Like having a timemachine)
- The system flow is similar to the real business flow. It reflects the ideas of the business.
- The real world is event driven, so it's easier to create a system using events.