pub struct ConnectionPool { /* private fields */ }Expand description
ConnectionPool represents pool of connections to DAPI nodes.
It can be cloned and shared between threads. Cloning the pool will create a new reference to the same pool.
Implementations§
Source§impl ConnectionPool
impl ConnectionPool
Sourcepub fn get(
&self,
prefix: PoolPrefix,
uri: &Uri,
settings: Option<&AppliedRequestSettings>,
) -> Option<PoolItem>
pub fn get( &self, prefix: PoolPrefix, uri: &Uri, settings: Option<&AppliedRequestSettings>, ) -> Option<PoolItem>
Get item from the pool for the given uri and settings.
§Arguments
prefix- Prefix for the item in the pool. Used to distinguish between Core and Platform clients.uri- URI of the node.settings- Applied request settings.
Sourcepub fn get_or_create<E>(
&self,
prefix: PoolPrefix,
uri: &Uri,
settings: Option<&AppliedRequestSettings>,
create: impl FnOnce() -> Result<PoolItem, E>,
) -> Result<PoolItem, E>
pub fn get_or_create<E>( &self, prefix: PoolPrefix, uri: &Uri, settings: Option<&AppliedRequestSettings>, create: impl FnOnce() -> Result<PoolItem, E>, ) -> Result<PoolItem, E>
Get value from cache or create it using provided closure.
If value is already in the cache, it will be returned.
If value is not in the cache, it will be created by calling create() and stored in the cache.
§Arguments
prefix- Prefix for the item in the pool. Used to distinguish between Core and Platform clients.uri- URI of the node.settings- Applied request settings.
Sourcepub fn get_or_create_with_generation<E>(
&self,
prefix: PoolPrefix,
uri: &Uri,
settings: Option<&AppliedRequestSettings>,
create: impl FnOnce() -> Result<PoolItem, E>,
) -> Result<(PoolItem, u64), E>
pub fn get_or_create_with_generation<E>( &self, prefix: PoolPrefix, uri: &Uri, settings: Option<&AppliedRequestSettings>, create: impl FnOnce() -> Result<PoolItem, E>, ) -> Result<(PoolItem, u64), E>
Like ConnectionPool::get_or_create, and also returns the generation the returned connection was pooled at (see ConnectionPool::generation).
The generation is read under the same lock that finds or stores the connection, so it is the returned connection’s own even when other threads replace it right afterwards.
Sourcepub fn put(
&self,
uri: &Uri,
settings: Option<&AppliedRequestSettings>,
value: PoolItem,
)
pub fn put( &self, uri: &Uri, settings: Option<&AppliedRequestSettings>, value: PoolItem, )
Put item into the pool for the given uri and settings.
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
Generation of the connection pooled most recently. Every connection put into the pool afterwards gets a higher generation.
Sourcepub fn remove_uri(&self, uri: &Uri, generation: u64)
pub fn remove_uri(&self, uri: &Uri, generation: u64)
Drop every connection to uri pooled at or before generation,
whatever its prefix and connection settings.
A request that misses its deadline may have been sent over a half-open connection: the network path died after the request left, and nothing on the idle channel would ever notice. Keeping it pooled would stall the next request sent to the same node, so the executor evicts it and the next request dials a fresh connection.
Connections pooled after generation stay. They were dialed after the
timed-out attempt took its connection, for example by a concurrent
request that already timed out on the same node and reconnected.
Trait Implementations§
Source§impl Clone for ConnectionPool
impl Clone for ConnectionPool
Source§fn clone(&self) -> ConnectionPool
fn clone(&self) -> ConnectionPool
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConnectionPool
impl Debug for ConnectionPool
Auto Trait Implementations§
impl Freeze for ConnectionPool
impl RefUnwindSafe for ConnectionPool
impl Send for ConnectionPool
impl Sync for ConnectionPool
impl Unpin for ConnectionPool
impl UnsafeUnpin for ConnectionPool
impl UnwindSafe for ConnectionPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<T, U> IntoPlatformVersioned<U> for Twhere
U: FromPlatformVersioned<T>,
impl<T, U> IntoPlatformVersioned<U> for Twhere
U: FromPlatformVersioned<T>,
§fn into_platform_versioned(self, platform_version: &PlatformVersion) -> U
fn into_platform_versioned(self, platform_version: &PlatformVersion) -> U
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].