Rust client library for CockroachDB: automatic
transaction retries on serialization conflicts (SQLSTATE 40001), follower reads,
multi-region row homing, CDC changefeeds, AI/vector search, Continuum support,
metrics, circuit breaker, and health checks.
The Rust sibling of the Spring Boot Starter, Go, Python, and .NET libraries. It follows the same core + adapter shape: a driver-agnostic core, a primary SQLx adapter, and an optional SeaORM adapter.
Rust has no runtime AOP, so the Spring annotations map to closures (
pool.execute_tx(|conn| ...), the Go model) with optional attribute macros (#[cockroachdb::transactional]) as annotation-style sugar.
| Crate | Purpose |
|---|---|
cockroachdb-core |
Driver-agnostic: retry policy, SQLSTATE classification, isolation, follower-read AOST builders, region (crdb_region column homing), middleware, circuit breaker, metrics/health traits, DDL helpers. |
cockroachdb-sqlx |
Primary adapter. Pool over sqlx::PgPool, execute_tx retry loop, follower-read queries, SQLSTATE classification for sqlx errors. |
cockroachdb-seaorm |
ORM adapter (ActiveModel) built on the SQLx core. |
cockroachdb-cdc |
Changefeed SQL builder + webhook sink handler + metrics. |
cockroachdb-ai |
pgvector VECTOR / C-SPANN similarity search + semantic/RAG. |
cockroachdb-continuum |
Continuum support: vCluster, Plenum, Aegis, MCP, Cloud. |
cockroachdb-macros |
Attribute macros (#[transactional], #[follower_read]) — the AOP analogue. |
cockroachdb-testing |
Test harness, concurrency runner, retry/follower simulators (no live cluster). |
Served from this repository's GitHub Pages sparse Cargo registry — no token
required. In .cargo/config.toml:
[registries.cockroachlabs]
index = "sparse+https://cockroachlabs.github.io/cockroachdb-rust-library/registry/"# Cargo.toml
[dependencies]
cockroachdb-sqlx = { version = "0.2", registry = "cockroachlabs" }Using a coding agent in an app that depends on this library? See the consumer
guide docs/agents/AGENTS.md. It explains what the
library already handles (40001 retries, follower reads, region homing, CDC,
Continuum) so the agent doesn't rebuild it, and links the CockroachDB docs an
agent should read.
It lives in two places: bundled inside the published cockroachdb-sqlx
crate (matching the version you depend on), and served from the site at
https://cockroachlabs.github.io/cockroachdb-rust-library/agents/AGENTS.md
(latest main, also indexed by /llms.txt). If they disagree, trust the
crate's copy for the version you have.
Apache-2.0. See LICENSE.