pub struct ChannelPool { /* private fields */ }Expand description
Self-managed pool of tonic’s Channels.
Implementations§
Source§impl ChannelPool
impl ChannelPool
Sourcepub async fn get_channel(&self) -> Option<(IpAddr, Channel)>
pub async fn get_channel(&self) -> Option<(IpAddr, Channel)>
Get a channel from the pool.
This function will return a channel if one is available, or None if no
channels are available.
§Selection algorithm
Currently, the channel is selected randomly from the pool of available channels. However, this behavior may change in the future.
§Additional DNS and broken connection checks
If no channels are available, the function will check the DNS and recheck connections to all servers currently marked as dead. To avoid spamming the DNS and other servers, this will be performed no more than once every 500ms.
If the above check is running while this function is called, the function will wait for the check to finish and return the result.
If the check is not running, but the last check was performed less than 500ms ago,
the function will return None immediately.
The specifics of this behavior are not set in stone and may change in the future.
Sourcepub async fn report_broken(&self, ip_address: impl Into<IpAddr>)
pub async fn report_broken(&self, ip_address: impl Into<IpAddr>)
Report a broken endpoint to the pool.
This function will remove the endpoint from the pool and add it to the list of currently dead servers.
Trait Implementations§
Source§impl Clone for ChannelPool
This is a shallow clone, meaning that the new pool will reference the same
resources as the original pool.
impl Clone for ChannelPool
This is a shallow clone, meaning that the new pool will reference the same resources as the original pool.
Auto Trait Implementations§
impl Freeze for ChannelPool
impl !RefUnwindSafe for ChannelPool
impl Send for ChannelPool
impl Sync for ChannelPool
impl Unpin for ChannelPool
impl !UnwindSafe for ChannelPool
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request