ljprs_es/lib.rs
1//! # ljprs_es
2//!
3//! Provides the core types to facilitate event sourcing in Rust.
4//!
5//! ## Logical Versions
6//! When event streams get large, there is considerable overhead in rebuilding
7//! the current state of an aggregate from all historical events. There are
8//! multiple approaches to reduce the impact that this can have, but this crate
9//! provides functionality to allow for state persisting.
10//!
11//! It does this by ensuring implementations of `State` can be serialized, and
12//! also ensures that implementations of `State` expose a "logical version".
13//!
14//! This `u32` value is used to version the logic used to produce the `State`
15//! from a stream of events.
16//!
17//! This allows implementations of `Store` to persist the current state of an
18//! aggregate to the backing data repository. When reading the stream, only the
19//! `State` needs to be read if we know the logic used to produce that state has
20//! not changed.
21//!
22//! The full event stream will only need to be read and aggregated if the logic
23//! used to produce the state has changed. For this reason, it is important to
24//! ensure the logical version of a `State` is incremented if the logic used to
25//! produce it changes.
26
27mod aggregate;
28mod event;
29mod state;
30mod store;
31
32pub use aggregate::Aggregate;
33pub use event::Event;
34pub use state::State;
35pub use store::Store;