pub struct Pool { /* private fields */ }Expand description
Thread-safe connection pool for VoltDB.
§Thread Safety
Pool is designed for high concurrency:
- Pool lock only guards metadata (microseconds)
- Each connection has its own lock for I/O
- Network I/O never blocks other threads from getting connections
§Example
ⓘ
use voltdb_client_rust::{Pool, PoolConfig, Opts, IpPort};
let hosts = vec![IpPort::new("localhost".to_string(), 21212)];
let config = PoolConfig::new().size(5);
let pool = Pool::with_config(Opts::new(hosts), config)?;
let mut conn = pool.get_conn()?;
let table = conn.query("SELECT * FROM foo")?;Implementations§
Source§impl Pool
impl Pool
Sourcepub fn new<T: Into<Opts>>(opts: T) -> Result<Pool, VoltError>
pub fn new<T: Into<Opts>>(opts: T) -> Result<Pool, VoltError>
Create a new pool with default configuration (10 connections).
Sourcepub fn new_manual<T: Into<Opts>>(
size: usize,
opts: T,
) -> Result<Pool, VoltError>
pub fn new_manual<T: Into<Opts>>( size: usize, opts: T, ) -> Result<Pool, VoltError>
Create a new pool with custom size (convenience method).
Sourcepub fn with_config<T: Into<Opts>>(
opts: T,
config: PoolConfig,
) -> Result<Pool, VoltError>
pub fn with_config<T: Into<Opts>>( opts: T, config: PoolConfig, ) -> Result<Pool, VoltError>
Create a new pool with full configuration.
Sourcepub fn get_conn(&self) -> Result<PooledConn<'_>, VoltError>
pub fn get_conn(&self) -> Result<PooledConn<'_>, VoltError>
Get a connection from the pool.
§Errors
PoolError::PoolShutdownif pool is shutting downPoolError::PoolExhaustedif no healthy connections (FailFast policy)PoolError::Timeoutif wait times out (Block policy)
Sourcepub fn shutdown(&self)
pub fn shutdown(&self)
Initiate graceful shutdown.
This method:
- Stops accepting new connections
- Closes all connections
Note: Since VoltDB connections are shared (multiple threads can use the same connection concurrently), we don’t track “active” connections. Shutdown simply prevents new checkouts and clears the connections.
Sourcepub fn is_shutdown(&self) -> bool
pub fn is_shutdown(&self) -> bool
Check if pool is shut down.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Pool
impl RefUnwindSafe for Pool
impl Send for Pool
impl Sync for Pool
impl Unpin for Pool
impl UnwindSafe for Pool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more