InstrumentablePool

Trait InstrumentablePool 

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

    // Required method
    fn get<'async_trait>(
        &'p self,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Resource, Error<Self::Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'p: 'async_trait;

    // Provided methods
    fn try_get(&'p self) -> Result<Self::Resource, Error<Self::Error>> { ... }
    fn get_timeout<'async_trait>(
        &'p self,
        _timeout: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Resource, Error<Self::Error>>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'p: 'async_trait { ... }
    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<'async_trait>( &'p self, ) -> Pin<Box<dyn Future<Output = Result<Self::Resource, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'p: 'async_trait,

Acquire 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, or if this operation is not implemented for this pool type.

Source

fn get_timeout<'async_trait>( &'p self, _timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<Self::Resource, Error<Self::Error>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'p: 'async_trait,

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> InstrumentablePool<'p> for Pool<M>

Source§

type Resource = PooledConnection<'p, M>

Source§

type Error = <M as ManageConnection>::Error

Source§

fn get<'async_trait>( &'p self, ) -> Pin<Box<dyn Future<Output = Result<Self::Resource, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'p: 'async_trait,

Source§

fn get_timeout<'async_trait>( &'p self, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<Self::Resource, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'p: 'async_trait,

Source§

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

Source§

impl<'p, M, W> InstrumentablePool<'p> for Pool<M, W>
where M: Manager, M::Error: Error + 'static, W: From<Object<M>> + 'p,

Source§

type Resource = W

Source§

type Error = <M as Manager>::Error

Source§

fn get<'async_trait>( &'p self, ) -> Pin<Box<dyn Future<Output = Result<Self::Resource, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'p: 'async_trait,

Source§

fn get_timeout<'async_trait>( &'p self, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<Self::Resource, Error<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'p: 'async_trait,

Source§

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

Implementors§