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§
Required Methods§
Provided Methods§
Sourcefn try_get(&'p self) -> Result<Self::Resource, Error<Self::Error>>
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.
Sourcefn get_timeout(
&'p self,
_timeout: Duration,
) -> Result<Self::Resource, Error<Self::Error>>
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.
Sourcefn get_state(&'p self) -> Result<PoolState, Error<Self::Error>>
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.