pub struct AsyncPool { /* private fields */ }Expand description
A pool of N AsyncConns for parallel PostgreSQL backend utilization. Detects dead connections and replaces them automatically.
Implementations§
Source§impl AsyncPool
impl AsyncPool
Sourcepub async fn connect(
addr: &str,
user: &str,
password: &str,
database: &str,
size: usize,
) -> Result<Arc<Self>, PgWireError>
pub async fn connect( addr: &str, user: &str, password: &str, database: &str, size: usize, ) -> Result<Arc<Self>, PgWireError>
Create a pool of size AsyncConns, each with its own TCP connection.
Sourcepub async fn connect_with_tls(
addr: &str,
user: &str,
password: &str,
database: &str,
size: usize,
tls_mode: TlsMode,
) -> Result<Arc<Self>, PgWireError>
pub async fn connect_with_tls( addr: &str, user: &str, password: &str, database: &str, size: usize, tls_mode: TlsMode, ) -> Result<Arc<Self>, PgWireError>
Create a pool with an explicit TLS mode.
Sourcepub async fn alive_count(&self) -> usize
pub async fn alive_count(&self) -> usize
Number of alive connections.
Sourcepub async fn close(&self) -> Result<(), PgWireError>
pub async fn close(&self) -> Result<(), PgWireError>
Close all connections in the pool by sending Terminate on each and waiting for the writer/reader tasks to exit. Idempotent: dead slots are skipped.
Sourcepub async fn exec_transaction(
&self,
setup_sql: &str,
query_sql: &str,
params: &[Option<&[u8]>],
param_oids: &[u32],
) -> Result<Vec<RawRow>, PgWireError>
pub async fn exec_transaction( &self, setup_sql: &str, query_sql: &str, params: &[Option<&[u8]>], param_oids: &[u32], ) -> Result<Vec<RawRow>, PgWireError>
Execute a pipelined transaction on the next available connection.
Sourcepub async fn exec_query(
&self,
sql: &str,
params: &[Option<&[u8]>],
param_oids: &[u32],
) -> Result<Vec<RawRow>, PgWireError>
pub async fn exec_query( &self, sql: &str, params: &[Option<&[u8]>], param_oids: &[u32], ) -> Result<Vec<RawRow>, PgWireError>
Execute a parameterized query on the next available connection.
Sourcepub async fn exec_query_with_formats(
&self,
sql: &str,
params: &[Option<&[u8]>],
param_oids: &[u32],
param_formats: &[FormatCode],
result_formats: &[FormatCode],
) -> Result<Vec<RawRow>, PgWireError>
pub async fn exec_query_with_formats( &self, sql: &str, params: &[Option<&[u8]>], param_oids: &[u32], param_formats: &[FormatCode], result_formats: &[FormatCode], ) -> Result<Vec<RawRow>, PgWireError>
Execute a parameterized query with explicit per-param and per-result format codes on the next available connection.
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 UnsafeUnpin 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