Skip to main content

keepsake_sqlx/
lib.rs

1//! `SQLx` adapter for Keepsake.
2//!
3//! Human guides and reference material are in the `docs/` directory of the
4//! repository. API reference: <https://docs.rs/keepsake-sqlx>.
5//!
6//! This crate provides Postgres, `SQLite`, and `MySQL` repositories for durable
7//! keepsake lifecycle state, relation reads, expiry workers, audit history, and
8//! audit outbox export.
9//!
10//! SQL audit writes performed by repository commands are transactional:
11//! `apply`, `revoke`, expiry helpers, and `append_audit_event` write the audit
12//! event and the corresponding outbox row in the same database transaction.
13//! External systems such as Kafka, Restate, S3, or warehouse loaders should
14//! consume the database outbox through `audit_outbox`,
15//! `claim_audit_outbox`, `ack_audit_outbox`, and `release_audit_outbox`; broker
16//! and storage clients intentionally stay outside this crate.
17
18mod repository;
19
20pub mod prelude {
21    //! Common imports for application modules using the `SQLx` adapter.
22
23    #[cfg(feature = "postgres")]
24    pub use crate::{KeepsakeRepository, PostgresKeepsakeRepository, TimedKeepsakeRepository};
25    #[cfg(feature = "mysql")]
26    pub use crate::{MySqlKeepsakeRepository, TimedMySqlKeepsakeRepository};
27    pub use crate::{RepositoryError, RepositoryResult};
28    #[cfg(feature = "sqlite")]
29    pub use crate::{SqliteKeepsakeRepository, TimedSqliteKeepsakeRepository};
30}
31
32pub use repository::{
33    ActiveRelation, AppliedKeepsake, AuditCursor, AuditEventRecord, AuditOutboxCursor,
34    AuditOutboxRecord, FulfilledExpiryCandidate, KeepsakeSqlxBackend, MembershipCursor,
35    NoopRelationCache, RelationCache, RepositoryError, RepositoryResult, SqlxKeepsakeRepository,
36    TimedExpiryCandidate, TimedSqlxKeepsakeRepository,
37};
38#[cfg(feature = "postgres")]
39pub use repository::{
40    KeepsakeRepository, PostgresBackend, PostgresKeepsakeRepository, TimedKeepsakeRepository,
41};
42#[cfg(feature = "cache")]
43pub use repository::{LocalRelationCache, LocalRelationCacheConfig};
44#[cfg(feature = "mysql")]
45pub use repository::{MySqlBackend, MySqlKeepsakeRepository, TimedMySqlKeepsakeRepository};
46#[cfg(feature = "sqlite")]
47pub use repository::{SqliteBackend, SqliteKeepsakeRepository, TimedSqliteKeepsakeRepository};