InstrumentablePool

Trait InstrumentablePool 

Source
pub trait InstrumentablePool<'p> {
    type Resource: 'p;
    type Error: Error + Send + 'static;

    // Required method
    fn get(&'p self) -> Result<Self::Resource, Error<Self::Error>>;

    // Provided methods
    fn try_get(&'p self) -> Result<Self::Resource, Error<Self::Error>> { ... }
    fn get_timeout(
        &'p self,
        _timeout: Duration,
    ) -> Result<Self::Resource, Error<Self::Error>> { ... }
    fn get_state(&'p self) -> Result<PoolState, Error<Self::Error>> { ... }
}
Expand description

Pool objects implementing this trait can be instrumented.

Required Associated Types§

Source

type Resource: 'p

Resource type contained in the pool.

Source

type Error: Error + Send + 'static

Error type use by the pool.

Required Methods§

Source

fn get(&'p self) -> Result<Self::Resource, Error<Self::Error>>

Acquire a resource from the pool.

§Errors

Returns Err if there was a problem acquiring a resource from the pool.

Provided Methods§

Source

fn try_get(&'p self) -> Result<Self::Resource, Error<Self::Error>>

Instantly acquire a resource from the pool.

§Errors

Returns Err if blocking is required, if there was a problem acquiring a resource from the pool, or if this operation is not implemented for this pool type.

Source

fn get_timeout( &'p self, _timeout: Duration, ) -> Result<Self::Resource, Error<Self::Error>>

Try to acquire a resource from the pool, waiting for a bounded time.

§Errors

Must return Error::AcquireTimeout if waiting time was exhaused.

Returns Error::NotImplemented if this operation is not implemented for this pool type.

Source

fn get_state(&'p self) -> Result<PoolState, Error<Self::Error>>

Get various internal pool counts and metrics.

This is in turn used to update OpenTelemetry metrics.

§Errors

Returns Err if there was a problem collecting pool state, or Error::NotImplemented if state collection is not implemented for this pool type.

Implementations on Foreign Types§

Source§

impl<'p, M: ManageConnection> InstrumentablePool<'p> for Pool<M>

Source§

type Resource = PooledConnection<M>

Source§

type Error = Error

Source§

fn get(&'p self) -> Result<Self::Resource, Error<Self::Error>>

Source§

fn try_get(&'p self) -> Result<Self::Resource, Error<Self::Error>>

Source§

fn get_timeout( &'p self, timeout: Duration, ) -> Result<Self::Resource, Error<Self::Error>>

Source§

fn get_state(&'p self) -> Result<PoolState, Error<Self::Error>>

Implementors§