4 ms·
when do you use cqrs/es ? is this like Datomic?
by ziont 8y ago
when do you use cqrs/es ?
is this like Datomic?
- spoudaia 8y agoTo cut a long story short: Event-sourcing as a persistence mechanism, where you store deltas instead of the current state, similar to what Git does. CQRS is a pattern to separate the write side from the read side of your application, with the goal of being able to scale both independently of each other. Regarding Datomic: I'm not an expert for Datomic, but AFAICS Datomic is primarily a database, while wolkenkit is an out-of-the-box full-featured framework for business logic, storage and so on.
- jen20 8y agoJust to clarify here: event sourcing is _not_ what Git does at all. Git stores complete snapshots of objects, not diffs [1]. Event sourcing itself is a fairly straightforward concept which the parent does sum up though - store events which describe what happened to an entity in a system rather than the resulting state. The state of an object can be derived via application of a left fold over the history. [1]: https://willi.am/blog/2014/10/14/for-the-last-time-git-stores-snapshots-not-diffs/ https://willi.am/blog/2014/10/14/for-the-last-time-git-store... - this is the best reference I can find quickly, though the git manual would obvioiusly be more authoritative.
- goloroden 8y agoAs said, "similar" to what Git does ;-) Conceptually, it's still capturing the deltas, instead of storing the current state and overwriting it. Storing the history is the key ingredient here, and of course, there are differences in how to achieve this.
- jen20 8y agoI would argue that there is a fundamental difference between the two: one stores the state and calculates the deltas, and the other stores the deltas and calculates the state. Both are common in systems, but only the latter is event sourcing - at least if the definition is to have any use and not become overloaded.
- linkmotif 8y agoYeah every time people say Git stores deltas it’s sad because the fun thing about Git is that it DOESNT store deltas.
- treve 8y agoThe text-book example for event-sourcing is accounting. To calculate the current balance of an account, you add up all past transactions. You don't need to store the balance (state) because you can deduce it by replaying all events. This gives a few nice advantages. For example, with this system in hand you can now also ask "What was the balance 30 days ago".