pub struct InstrumentedPool<P> { /* private fields */ }Expand description
Instrumented pool.
Automatically gathers pool-related metrics and provides relevant traces.
Implementations§
Source§impl<P, E> InstrumentedPool<P>
impl<P, E> InstrumentedPool<P>
Sourcepub fn instrument<L: Into<Cow<'static, str>>>(
label: Option<L>,
pool: P,
) -> Result<Self, Error<E>>
pub fn instrument<L: Into<Cow<'static, str>>>( label: Option<L>, pool: P, ) -> Result<Self, Error<E>>
Instrument provided resource pool.
§Errors
Returns Err if there was a problem collecting pool state.
Sourcepub fn update_metrics(&self) -> Result<(), Error<E>>
pub fn update_metrics(&self) -> Result<(), Error<E>>
Manually update pool metrics.
Normally you wouldn’t need to call this directly, as metrics collection occurs automatically as you use the pool.
§Errors
Returns Err if there was a problem collecting pool state.
Sourcepub async fn get(
&self,
) -> Result<InstrumentedResource<<P as InstrumentablePool<'_>>::Resource>, Error<E>>
pub async fn get( &self, ) -> Result<InstrumentedResource<<P as InstrumentablePool<'_>>::Resource>, Error<E>>
Acquire instrumented resource from resource pool.
§Errors
Returns Err if there was a problem acquiring a resource from the pool.
Sourcepub fn try_get(
&self,
) -> Result<InstrumentedResource<<P as InstrumentablePool<'_>>::Resource>, Error<E>>
pub fn try_get( &self, ) -> Result<InstrumentedResource<<P as InstrumentablePool<'_>>::Resource>, Error<E>>
Instantly acquire an instrumented resource from the pool.
§Errors
Returns Err if blocking is required, or if this operation is not implemented for this
pool type.
Sourcepub async fn get_timeout(
&self,
timeout: Duration,
) -> Result<InstrumentedResource<<P as InstrumentablePool<'_>>::Resource>, Error<E>>
pub async fn get_timeout( &self, timeout: Duration, ) -> Result<InstrumentedResource<<P as InstrumentablePool<'_>>::Resource>, Error<E>>
Try to acquire an instrumented 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.