entelix_persistence/lib.rs
1//! # entelix-persistence
2//!
3//! Postgres + Redis backends for the three storage traits owned by
4//! other crates: [`entelix_graph::Checkpointer`],
5//! [`entelix_memory::Store`], and the session event log
6//! ([`entelix_session::SessionGraph`]). Each backend is a
7//! `*Persistence` bundle — a single builder produces a
8//! `(Checkpointer, Store, SessionLog)` triplet sharing one connection
9//! pool / lock backend.
10//!
11//! Distributed session locking lives behind the [`DistributedLock`]
12//! trait; [`with_session_lock`] composes lock acquisition with a
13//! caller closure (invariant 8 — durable session writes happen under
14//! a lock).
15//!
16//! Cargo features:
17//! - `postgres` — pulls `sqlx`, enables the `postgres` module.
18//! - `redis` — pulls `redis`, enables the `redis` module.
19//! - `test-containers` — pulls `testcontainers` for ephemeral docker
20//! integration tests; implies both backends.
21
22#![cfg_attr(docsrs, feature(doc_cfg))]
23#![doc(html_root_url = "https://docs.rs/entelix-persistence/0.5.3")]
24#![deny(missing_docs)]
25// Backend modules cross-translate `sqlx`/`redis` errors many times; the
26// `&Error` form fights with the implicit `Into` conversions sqlx
27// returns. The cast lints below are exercised by integer-space
28// arithmetic in serialisation; we audit at the call sites.
29#![allow(
30 clippy::needless_pass_by_value,
31 clippy::missing_const_for_fn,
32 clippy::redundant_closure,
33 clippy::redundant_closure_for_method_calls,
34 clippy::cast_possible_truncation,
35 clippy::cast_precision_loss,
36 clippy::cast_sign_loss,
37 clippy::cast_lossless,
38 clippy::cast_possible_wrap,
39 clippy::indexing_slicing,
40 clippy::expect_used,
41 clippy::single_match_else,
42 clippy::manual_let_else,
43 clippy::needless_pass_by_ref_mut
44)]
45
46pub mod advisory_key;
47pub mod error;
48pub mod lock;
49pub mod schema_version;
50
51#[cfg(feature = "postgres")]
52#[cfg_attr(docsrs, doc(cfg(feature = "postgres")))]
53pub mod postgres;
54
55#[cfg(feature = "redis")]
56#[cfg_attr(docsrs, doc(cfg(feature = "redis")))]
57pub mod redis;
58
59pub use advisory_key::AdvisoryKey;
60pub use error::{PersistenceError, PersistenceResult};
61pub use lock::{DistributedLock, LockGuard, with_session_lock};
62pub use schema_version::SessionSchemaVersion;