Skip to content

cntm-labs/sentinel-driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

149 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

sentinel-driver

High-performance PostgreSQL wire protocol driver for Rust. PG-only, zero-copy, pipeline-first.

CI PostgreSQL Integration codecov

crates.io sentinel-driver crates.io sentinel-derive docs.rs

Rust Shell Total Lines

Rust Tokio PostgreSQL rustls


Foundation layer for Sentinel ORM. Can be used independently as a standalone PostgreSQL driver.

Quick Start

[dependencies]
sentinel-driver = "0.1"
use sentinel_driver::{Config, Connection};

#[tokio::main]
async fn main() -> Result<(), sentinel_driver::Error> {
    let config = Config::parse("postgres://user:pass@localhost/mydb")?;
    let mut conn = Connection::connect(config).await?;

    let rows = conn.query("SELECT id, name FROM users WHERE id = $1", &[&42i32]).await?;
    for row in &rows {
        let id: i32 = row.get(0);
        let name: String = row.get(1);
    }

    Ok(())
}

Features

  • SCRAM-SHA-256 with correct SASLprep (where sqlx gets it wrong)
  • Pipeline mode (PG 14+) -- batch queries in a single round-trip
  • COPY protocol -- bulk insert 10-50x faster than INSERT
  • LISTEN/NOTIFY -- first-class realtime notifications
  • Cancel query -- CancelToken for safe query cancellation from any task
  • Per-query timeout -- auto-cancel with configurable statement_timeout
  • Two-tier statement cache -- HashMap + LRU-256, ~99% hit rate
  • Connection pool -- deadpool-style, <0.5 us checkout
  • Binary format by default -- 15-40% faster for non-text types
  • Zero-copy -- bytes::Bytes slices for large column values
  • Array types -- Vec<T> encode/decode for PostgreSQL arrays
  • rustls -- no OpenSSL dependency

Architecture

crates/
├── sentinel-driver    # Main driver crate — connection, protocol, pool, types
└── sentinel-derive    # Derive macros — FromRow, ToSql, FromSql

Performance Targets

Metric Target
Simple SELECT 90K+ queries/s
Batch 100 queries 15K+ batches/s
Bulk INSERT 10K rows 500K+ rows/s
Pool checkout <0.5 us
Statement cache hit rate ~99%

Development

cargo check --workspace                  # Type check
cargo test --workspace                   # Run all tests
cargo clippy --workspace -- -D warnings  # Lint
cargo fmt --all                          # Format

# Setup pre-commit hook
git config core.hooksPath .githooks

MSRV

Rust 1.75 (declared via rust-version in Cargo.toml).

License

Licensed under either of:

at your option.

About

High-performance PostgreSQL wire protocol driver for Rust

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages