Skip to main content

Module db

Module db 

Source
Expand description

Unified database facade — one handle, three ecosystems.

ArclyDbPool is the single type user code injects regardless of which driver is compiled in (db-sqlx, db-seaorm, db-diesel). It implements DataSource, so it slots straight into the existing DataSourceRegistry — tenant routing, read/write splitting, and ReadAfterWritePin all apply unchanged, because primary/replica selection happens here at the facade, before any driver is touched.

§Zero-lock guarantees

  • Replica selection: one AtomicUsize round-robin.
  • SQLx / SeaORM pools are internally lock-free async acquires.
  • Diesel (sync core) never runs on a worker thread: both pool.get() and the query closure execute inside spawn_blocking (see data::drivers::diesel).

§Feature gating

This module always compiles. Driver variants exist only when their Cargo feature is enabled; with no db-* feature, the enums are uninhabited and every operation reports a configuration error at the call site.

Structs§

ArclyDbPool
Primary + replicas for one logical database. Build at boot (plugin on_init), register into DataSourceRegistry<ArclyDbPool>, freeze.
DbHealthCheck
Readiness probe over every pool in a DataSourceRegistry: pings each primary and reports the first failure as Unhealthy naming the pool.

Enums§

DbDriver
One concrete connection pool. Variants are feature-gated; constructors live in data::drivers::*.
OwnedDbConn
An acquired handle, decoupled from the pool’s lifetime so it can be held across .await points and moved into transactions.