pub struct AsyncPool { /* private fields */ }Expand description
Thread-safe async connection pool for VoltDB.
§Example
ⓘ
use voltdb_client_rust::{AsyncPool, AsyncPoolConfig, Opts, IpPort};
let hosts = vec![IpPort::new("localhost".to_string(), 21212)];
let config = AsyncPoolConfig::new().size(5);
let pool = AsyncPool::with_config(Opts::new(hosts), config).await?;
let conn = pool.get_conn().await?;
let table = conn.query("SELECT * FROM foo").await?;Implementations§
Source§impl AsyncPool
impl AsyncPool
Sourcepub async fn new<T: Into<Opts>>(opts: T) -> Result<AsyncPool, VoltError>
pub async fn new<T: Into<Opts>>(opts: T) -> Result<AsyncPool, VoltError>
Create a new pool with default configuration (10 connections).
Sourcepub async fn new_manual<T: Into<Opts>>(
size: usize,
opts: T,
) -> Result<AsyncPool, VoltError>
pub async fn new_manual<T: Into<Opts>>( size: usize, opts: T, ) -> Result<AsyncPool, VoltError>
Create a new pool with custom size (convenience method).
Sourcepub async fn with_config<T: Into<Opts>>(
opts: T,
config: AsyncPoolConfig,
) -> Result<AsyncPool, VoltError>
pub async fn with_config<T: Into<Opts>>( opts: T, config: AsyncPoolConfig, ) -> Result<AsyncPool, VoltError>
Create a new pool with full configuration.
Sourcepub async fn get_conn(&self) -> Result<AsyncPooledConn<'_>, VoltError>
pub async fn get_conn(&self) -> Result<AsyncPooledConn<'_>, VoltError>
Get a connection from the pool.
Sourcepub fn is_shutdown(&self) -> bool
pub fn is_shutdown(&self) -> bool
Check if pool is shut down.
Sourcepub async fn stats(&self) -> AsyncPoolStats
pub async fn stats(&self) -> AsyncPoolStats
Get current pool statistics.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AsyncPool
impl !RefUnwindSafe for AsyncPool
impl Send for AsyncPool
impl Sync for AsyncPool
impl Unpin for AsyncPool
impl !UnwindSafe for AsyncPool
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