Skip to main content

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#![cfg_attr(docsrs, feature(doc_cfg))]
18
19#[cfg(not(any(feature = "postgres", feature = "mysql", feature = "sqlite")))]
20compile_error!(
21    "hexeract-outbox-sql requires at least one backend feature: `postgres`, `mysql` or `sqlite`"
22);
23
24/// SQL dialect differences absorbed by the backend stores.
25pub mod dialect;
26mod envelope;
27mod validate;
28
29#[cfg(feature = "postgres")]
30/// PostgreSQL backend backed by `sqlx::PgPool`.
31pub mod postgres;
32
33#[cfg(feature = "mysql")]
34/// MySQL backend backed by `sqlx::MySqlPool`.
35pub mod mysql;
36
37#[cfg(feature = "sqlite")]
38/// SQLite backend backed by `sqlx::SqlitePool`.
39pub mod sqlite;
40
41pub use dialect::Dialect;
42
43#[cfg(feature = "postgres")]
44pub use postgres::{PgOutboxPublisher, PgOutboxStore, PgOutboxWorkerBuilder};
45
46#[cfg(feature = "mysql")]
47pub use mysql::{MySqlOutboxPublisher, MySqlOutboxStore, MySqlOutboxWorkerBuilder};
48
49#[cfg(feature = "sqlite")]
50pub use sqlite::{SqliteOutboxPublisher, SqliteOutboxStore, SqliteOutboxWorkerBuilder};
51
52/// Default outbox table name used when a builder's `table_name` is not set.
53pub const DEFAULT_TABLE_NAME: &str = "audit_outbox";