hexeract_outbox_sql/lib.rs
1//! SQL backends for the Hexeract outbox, built on `sqlx`.
2//!
3//! This crate implements the backend-agnostic [`hexeract_outbox`] contracts
4//! ([`OutboxStore`], [`OutboxPublisher`]) on top of `sqlx`, with one
5//! compile-time backend per Cargo feature:
6//!
7//! - `postgres` (default): [`PgOutboxStore`] / [`PgOutboxPublisher`]
8//! - `mysql`: `MySqlOutboxStore` / `MySqlOutboxPublisher`
9//! - `sqlite`: `SqliteOutboxStore` / `SqliteOutboxPublisher`
10//!
11//! The SQL dialect differences (placeholder style, row locking, timestamp
12//! handling and schema DDL) are centralized in [`Dialect`], so the per-backend
13//! stores share the statement templating and the envelope assembly logic.
14//!
15//! [`OutboxStore`]: hexeract_outbox::OutboxStore
16//! [`OutboxPublisher`]: hexeract_outbox::OutboxPublisher
17
18#[cfg(not(any(feature = "postgres", feature = "mysql", feature = "sqlite")))]
19compile_error!(
20 "hexeract-outbox-sql requires at least one backend feature: `postgres`, `mysql` or `sqlite`"
21);
22
23/// SQL dialect differences absorbed by the backend stores.
24pub mod dialect;
25mod envelope;
26mod validate;
27
28#[cfg(feature = "postgres")]
29/// PostgreSQL backend backed by `sqlx::PgPool`.
30pub mod postgres;
31
32#[cfg(feature = "mysql")]
33/// MySQL backend backed by `sqlx::MySqlPool`.
34pub mod mysql;
35
36#[cfg(feature = "sqlite")]
37/// SQLite backend backed by `sqlx::SqlitePool`.
38pub mod sqlite;
39
40pub use dialect::Dialect;
41
42#[cfg(feature = "postgres")]
43pub use postgres::{PgOutboxPublisher, PgOutboxStore, PgOutboxWorkerBuilder};
44
45#[cfg(feature = "mysql")]
46pub use mysql::{MySqlOutboxPublisher, MySqlOutboxStore, MySqlOutboxWorkerBuilder};
47
48#[cfg(feature = "sqlite")]
49pub use sqlite::{SqliteOutboxPublisher, SqliteOutboxStore, SqliteOutboxWorkerBuilder};
50
51/// Default outbox table name used when a builder's `table_name` is not set.
52pub const DEFAULT_TABLE_NAME: &str = "audit_outbox";