Now I trying to use Event Sourcing (mainly for sync) for a "normal" invoice app, I find several problems. The thing is that the event log is good for write but awful for read. Re-compute everything is problematic and the true is 90% of the time you want the last version, not all the history. Also, the split in logic from the app / engine is stupid. I think is good if we move past the idea that the DB engine is more dumb than a rock, and embrace it. But current tools are not ideal (sadly, I know what is live like this: I have used Visual FoxPro!)
Where I think this could lead to something great is if the DB is alike this:
- Relational
- You have normal tables. Consider them your up-to-date cache. Most scenarios will be covered here (ie: The log recomputing is NOT at the app level, but at the DB level).
- You have a event log where everything is stored, plus your "tables" for the info you need up-to-date. But you don't need all to be a table if not make sense, and do full re-computation if desired.
- Your backup, sync and load history is around the event log.
- You don't even need a "table" if you wanna only a "index", this lead to me:
- You submit a data request (like a POST), and the DB convert it to the tables and log, but:
- You can instead (or also!) hook here and build secondary indexes and do other stuff. You can do it async, put the computation in a queue, do validations, etc as fit.
So, what is not here and need tooling is marry the "normal tables" + "event log" + "logic that route this", so putting:
Data -> WAL -> Router -> Event Log | Tables | Index | ping external tools
And
Request Data -> Router -> Get it from:Event Log | Tables | Index | ping external tools