1 unstable release
0.1.0 | Apr 27, 2023 |
---|
#24 in #facilitate
14KB
ljprs_es
Provides the core types to facilitate event sourcing in Rust.
lib.rs
:
ljprs_es
Provides the core types to facilitate event sourcing in Rust.
Logical Versions
When event streams get large, there is considerable overhead in rebuilding the current state of an aggregate from all historical events. There are multiple approaches to reduce the impact that this can have, but this crate provides functionality to allow for state persisting.
It does this by ensuring implementations of State
can be serialized, and
also ensures that implementations of State
expose a "logical version".
This u32
value is used to version the logic used to produce the State
from a stream of events.
This allows implementations of Store
to persist the current state of an
aggregate to the backing data repository. When reading the stream, only the
State
needs to be read if we know the logic used to produce that state has
not changed.
The full event stream will only need to be read and aggregated if the logic
used to produce the state has changed. For this reason, it is important to
ensure the logical version of a State
is incremented if the logic used to
produce it changes.
Dependencies
~0.3–1MB
~22K SLoC