deadpool-oracle
Async connection pool for Oracle databases using oracle-rs and deadpool.
Features
- Async connection pooling - Built on the
deadpoolasync pool library - Automatic connection health checks - Connections are verified before reuse
- Configurable pool size and timeouts - Tune for your workload
- Automatic cleanup - Pending transactions are rolled back on connection return
Quick Start
Add to your Cargo.toml:
[]
= "0.1"
= "0.1"
= { = "1", = ["rt-multi-thread", "macros"] }
Basic usage:
use Config;
use ;
async
Pool Configuration
use Config;
use PoolBuilder;
use Duration;
let config = new;
let pool = new
// Maximum number of connections (default: num_cpus * 4)
.max_size
// Timeout waiting for a connection from pool (default: 30s)
.wait_timeout
// Timeout for creating new connections (default: 30s)
.create_timeout
// Timeout for health checks on recycled connections (default: 5s)
.recycle_timeout
.build?;
Extension Trait
For convenience, you can create pools directly from a Config:
use Config;
use ConfigExt;
let config = new;
// Create pool with default settings
let pool = config.into_pool?;
// Or with custom max size
let pool = config.into_pool_with_size?;
Pool Status
let status = pool.status;
println!;
println!;
println!;
Connection Lifecycle
When a connection is returned to the pool (dropped), the following happens:
- Any pending transaction is rolled back
- The connection is verified with a ping
- If healthy, the connection is returned to the pool
- If unhealthy, the connection is discarded
This ensures that each connection from the pool is in a clean, working state.
With TLS/SSL
use Config;
use PoolBuilder;
let config = new
.with_tls?;
let pool = new
.max_size
.build?;
With DRCP (Database Resident Connection Pooling)
For maximum efficiency with Oracle DRCP:
use Config;
use PoolBuilder;
let config = new
.with_drcp;
// Client-side pool works with server-side DRCP
let pool = new
.max_size // Can be larger since DRCP handles server-side pooling
.build?;
Author
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.