pub struct PgPool { /* private fields */ }Expand description
Implementations§
Source§impl PgPool
impl PgPool
Sourcepub async fn from_config() -> PgResult<Self>
pub async fn from_config() -> PgResult<Self>
Sourcepub async fn connect(config: PoolConfig) -> PgResult<Self>
pub async fn connect(config: PoolConfig) -> PgResult<Self>
Create a new connection pool.
Sourcepub async fn acquire(&self) -> PgResult<PooledConnection>
pub async fn acquire(&self) -> PgResult<PooledConnection>
Acquire a connection from the pool.
Sourcepub async fn acquire_with_rls(
&self,
ctx: RlsContext,
) -> PgResult<PooledConnection>
pub async fn acquire_with_rls( &self, ctx: RlsContext, ) -> PgResult<PooledConnection>
Acquire a connection with RLS context pre-configured.
Sets PostgreSQL session variables for tenant isolation before returning the connection. When the connection is dropped, it automatically clears the RLS context before returning to the pool.
§Example
ⓘ
use qail_core::rls::RlsContext;
let mut conn = pool.acquire_with_rls(
RlsContext::operator("550e8400-e29b-41d4-a716-446655440000")
).await?;
// All queries through `conn` are now scoped to this operatorSourcepub async fn idle_count(&self) -> usize
pub async fn idle_count(&self) -> usize
Get the current number of idle connections.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Get the number of connections currently in use.
Sourcepub fn max_connections(&self) -> usize
pub fn max_connections(&self) -> usize
Get the maximum number of connections.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PgPool
impl !RefUnwindSafe for PgPool
impl Send for PgPool
impl Sync for PgPool
impl Unpin for PgPool
impl !UnwindSafe for PgPool
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