Skip to main content

lora_wal/
lib.rs

1//! Write-ahead log for LoraDB.
2//!
3//! `lora-wal` is the additive durability layer that sits between
4//! [`lora_store::MutationEvent`] producers (the in-memory engine) and a
5//! durable byte stream on disk. It is deliberately separate from
6//! `lora-store`:
7//!
8//! - `lora-store` stays storage-only — backends do not learn about logs,
9//!   segments, or fsync. The mutation surface they already expose
10//!   (`MutationEvent` + `MutationRecorder`) is the only seam.
11//! - `lora-wal` owns segment files, framing, replay, and truncation.
12//!   Consumers depending on the no-WAL story (wasm, embedded read-only)
13//!   can avoid this crate entirely.
14//! - `lora-database` glues the two together: it installs a [`WalRecorder`]
15//!   onto the store and brackets each query with `arm` / `commit` /
16//!   `abort` markers so replay sees query-atomic units even though the
17//!   recorder fires per primitive mutation.
18//!
19//! See `docs/decisions/0004-wal.md` for the full design and
20//! `docs/operations/wal.md` for operator-facing semantics.
21
22mod codec;
23mod config;
24mod dir;
25mod errors;
26mod history;
27mod io;
28mod lock;
29mod lsn;
30mod record;
31mod recorder;
32mod replay;
33mod segment;
34#[cfg(test)]
35mod testing;
36mod wal;
37
38// ---- Operator-facing surface ----------------------------------------------
39//
40// Everything below is what callers (`lora-database`, the HTTP server,
41// admin paths, integration tests) need. Internal types — segment
42// framing constants, the segment reader/writer, record codec — stay
43// `pub(crate)`. Bumping that boundary later is opt-in and easy; the
44// reverse (un-publishing a previously-public type) breaks downstream
45// builds.
46
47pub use config::{SyncMode, WalConfig};
48pub use dir::SegmentId;
49pub use errors::WalError;
50pub use history::{oldest_retained_lsn, CommittedTx, CommittedTxReader};
51pub use lsn::Lsn;
52pub use recorder::{
53    WalBufferedCommitError, WalCommitError, WalMirror, WalPoisonError, WalRecorder, WroteCommit,
54};
55pub use replay::{replay_dir, ReplayOutcome, TornTailInfo};
56pub use wal::Wal;