Expand description
An embedded, append-only event log.
eventsdb is an event store that lives in the process rather than behind
a socket. It keeps the guarantees an event store exists for — immutable
facts, per-stream ordering, decisions taken inside the write, schema
evolution without rewriting stored bytes — and drops the ones that require
a cluster.
§The layers
| Layer | What it answers |
|---|---|
event | what a valid event is, and which fields the store owns |
upcast | how a reader sees an old event’s current shape |
store | one stream: append, decide-and-append, read, head |
log | the database: read across streams, subscribe, checkpoint |
This crate is the contract and the in-memory backend. A durable backend is a separate crate implementing the same two traits.
§What single-writer buys
Two properties this design has are not available to a store that runs as a separate service, and both come from the same place — one writer, one transaction:
- Positions have no holes. The backend allocates a
position::Positioninside the transaction that commits it, so a reader never seesn + 1whilenis still uncommitted. Following the log is a range read, with no gap detection and no grace window. - A projection can be exactly-once. When the read model lives in the same database as the log, applying an event and advancing the consumer’s checkpoint are one transaction. There is no dedupe table and no idempotence requirement on the projection author.
Distributing the store forfeits both.
Re-exports§
pub use error::Error;pub use error::Result;pub use event::validate;pub use event::CURRENT_SCHEMA_VERSION;pub use log::EventLog;pub use log::Filter;pub use mem::MemEventStore;pub use params::Params;pub use position::Committed;pub use position::Position;pub use position::Recorded;pub use store::Decision;pub use store::EventStore;pub use store::Expected;pub use transfer::ExportedEvent;pub use transfer::ImportReport;pub use upcast::Current;pub use upcast::UpcastChain;pub use upcast::Upcaster;
Modules§
- error
- The error a store call can fail with.
- event
- The event envelope: what a caller may write, and what the store stamps.
- log
- The database-level SPI: one level above a stream.
- mem
- The in-memory backend.
- params
- What a caller binds into its own SQL.
- position
- Coordinates: where an event sits in its stream, and in the database.
- store
- The per-stream SPI.
- transfer
- Moving a log somewhere else, and getting the same log back.
- upcast
- Schema evolution: stored bytes are never rewritten, readers are moved forward instead.