| Crates.io | deadpool-oracle |
| lib.rs | deadpool-oracle |
| version | 0.1.1 |
| created_at | 2025-12-15 21:21:51.761096+00 |
| updated_at | 2025-12-18 19:23:10.647134+00 |
| description | Deadpool connection pool for oracle-rs |
| homepage | https://github.com/stiang/deadpool-oracle |
| repository | https://github.com/stiang/deadpool-oracle |
| max_upload_size | |
| id | 1986780 |
| size | 69,247 |
Async connection pool for Oracle databases using oracle-rs and deadpool.
deadpool async pool libraryAdd to your Cargo.toml:
[dependencies]
oracle-rs = "0.1"
deadpool-oracle = "0.1"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
Basic usage:
use oracle_rs::Config;
use deadpool_oracle::{Pool, PoolBuilder};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create connection config
let config = Config::new("localhost", 1521, "FREEPDB1", "user", "password");
// Create pool with default settings
let pool = PoolBuilder::new(config)
.max_size(10)
.build()?;
// Get a connection from the pool
let conn = pool.get().await?;
// Use the connection
let result = conn.query("SELECT * FROM users", &[]).await?;
println!("Found {} rows", result.row_count());
// Connection is automatically returned to the pool when dropped
Ok(())
}
use oracle_rs::Config;
use deadpool_oracle::PoolBuilder;
use std::time::Duration;
let config = Config::new("localhost", 1521, "FREEPDB1", "user", "password");
let pool = PoolBuilder::new(config)
// Maximum number of connections (default: num_cpus * 4)
.max_size(20)
// Timeout waiting for a connection from pool (default: 30s)
.wait_timeout(Some(Duration::from_secs(60)))
// Timeout for creating new connections (default: 30s)
.create_timeout(Some(Duration::from_secs(30)))
// Timeout for health checks on recycled connections (default: 5s)
.recycle_timeout(Some(Duration::from_secs(5)))
.build()?;
For convenience, you can create pools directly from a Config:
use oracle_rs::Config;
use deadpool_oracle::ConfigExt;
let config = Config::new("localhost", 1521, "FREEPDB1", "user", "password");
// Create pool with default settings
let pool = config.into_pool()?;
// Or with custom max size
let pool = config.into_pool_with_size(20)?;
let status = pool.status();
println!("Pool size: {}", status.size);
println!("Available connections: {}", status.available);
println!("Waiting tasks: {}", status.waiting);
When a connection is returned to the pool (dropped), the following happens:
This ensures that each connection from the pool is in a clean, working state.
use oracle_rs::Config;
use deadpool_oracle::PoolBuilder;
let config = Config::new("hostname", 2484, "service_name", "user", "password")
.with_tls()?;
let pool = PoolBuilder::new(config)
.max_size(10)
.build()?;
For maximum efficiency with Oracle DRCP:
use oracle_rs::Config;
use deadpool_oracle::PoolBuilder;
let config = Config::new("hostname", 1521, "service_name", "user", "password")
.with_drcp("my_app_pool", "self");
// Client-side pool works with server-side DRCP
let pool = PoolBuilder::new(config)
.max_size(50) // Can be larger since DRCP handles server-side pooling
.build()?;
Licensed under either of:
at your option.