This project explores:
- state synchronization among intermittently-connected instances of an app (e.g. mobile and desktop versions of a calendar) through dumb, resilient channels instead of centralized servers;
- from-scratch implementation of CQRS, Event Sourcing, and the Hexagonal (aka Ports & Adapters) architecture in Rust.
The sample implementation is a basic bookmark manager. To launch:
$ cargo run
Then open http://localhost:9111
.
Work in progress.
In Event Sourcing, individual events are immutable, and the representation of history (the event log) changes linearly, in parallel with time.
In this experiment, individual events are immutable, but not necessarily known: some of them may have been recorded in the past by another instance that is still offline. The representation of history isn't definitive, and may be amended by taking into account previously unknown events, much like in human history. Rather than a derivation of a perfectly known history, application state is an interpretation of a partially unknown one.
How this may look like in practice:
- In response to user actions, an app instance adds an event to a log (e.g.
BookmarkCreated
). - The event log is serialized to a disk folder, one file per event.
- When possible, each instance makes its log available to other instances via e.g. Syncthing), Dropbox, or even a USB stick.
- Each instance computes its own interpretation of the thus-far known history by replaying events from all logs.