pub struct ConnectionPool { /* private fields */ }Expand description
Wrapper around the lock-free connection pool.
Implementations§
Source§impl ConnectionPool
impl ConnectionPool
pub async fn new(connection_string: &str, config: PoolConfig) -> Result<Self>
Sourcepub async fn with_statement_timeout(
connection_string: &str,
config: PoolConfig,
statement_timeout: Duration,
) -> Result<Self>
pub async fn with_statement_timeout( connection_string: &str, config: PoolConfig, statement_timeout: Duration, ) -> Result<Self>
Create a pool whose connections enforce a server-side statement_timeout.
A non-zero statement_timeout caps how long any single query may run,
preventing a slow/runaway query from pinning a pooled connection
indefinitely. A value of Duration::ZERO leaves PostgreSQL’s default
(unlimited) in place.
Sourcepub async fn with_session_setup(
connection_string: &str,
config: PoolConfig,
statement_timeout: Duration,
read_only: bool,
) -> Result<Self>
pub async fn with_session_setup( connection_string: &str, config: PoolConfig, statement_timeout: Duration, read_only: bool, ) -> Result<Self>
Create a pool, optionally enforcing statement_timeout and a read-only
default transaction mode on every connection.
When read_only is true, each connection runs
SET default_transaction_read_only = on, so every statement (including
volatile functions invoked from a SELECT) is rejected at the database if
it attempts a write — a stronger guarantee than tool-name filtering.
Sourcepub async fn acquire(&self) -> MCPResult<PooledConnection<Client>>
pub async fn acquire(&self) -> MCPResult<PooledConnection<Client>>
Acquire a connection from the pool.
Returns a PooledConnection<Client> which implements Deref<Target = Client>
and automatically returns to the pool when dropped.
Sourcepub fn release(&self, _conn: PooledConnection<Client>)
pub fn release(&self, _conn: PooledConnection<Client>)
Release a connection back to the pool.
With PooledConnection, this is automatic on Drop. This method
exists for backward compatibility with existing callers.