pub struct ClientPool<F, P>where
F: ClientFacts,
P: ClientTransport,{ /* private fields */ }Expand description
Connection pool to the one server address (supports async and blocking context)
There’s a worker accepting task post in bounded channel.
Even when the server address is not reachable, the worker coroutine will not exit, until ClientPool is dropped.
The background coroutine will:
- monitor the address with ping task (action 0)
- cleanup the task in channel with error_handle when the address is unhealthy
If the connection is healthy and there’s incoming, the worker will spawn another coroutine for monitor purpose.
considering:
- The task incoming might never stop until faulty pool remove from pools collection
- If ping mixed with task with real business, might blocked due to throttler of in-flight message in the stream.
Implementations§
Source§impl<F, P> ClientPool<F, P>where
F: ClientFacts,
P: ClientTransport,
impl<F, P> ClientPool<F, P>where
F: ClientFacts,
P: ClientTransport,
pub fn new(facts: Arc<F>, addr: &str, channel_size: usize) -> ClientPool<F, P>
pub fn is_healthy(&self) -> bool
pub fn get_addr(&self) -> &str
pub async fn send_req(&self, task: <F as ClientFacts>::Task)
pub fn send_req_blocking(&self, task: <F as ClientFacts>::Task)
pub fn spawn(&self)
Trait Implementations§
Source§impl<F, P> ClientCaller for ClientPool<F, P>where
F: ClientFacts,
P: ClientTransport,
impl<F, P> ClientCaller for ClientPool<F, P>where
F: ClientFacts,
P: ClientTransport,
Source§impl<F, P> ClientCallerBlocking for ClientPool<F, P>where
F: ClientFacts,
P: ClientTransport,
impl<F, P> ClientCallerBlocking for ClientPool<F, P>where
F: ClientFacts,
P: ClientTransport,
type Facts = F
fn send_req_blocking(&self, task: <F as ClientFacts>::Task)
Source§impl<F, P> Clone for ClientPool<F, P>where
F: ClientFacts,
P: ClientTransport,
impl<F, P> Clone for ClientPool<F, P>where
F: ClientFacts,
P: ClientTransport,
Source§fn clone(&self) -> ClientPool<F, P>
fn clone(&self) -> ClientPool<F, P>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<F, P> !Freeze for ClientPool<F, P>
impl<F, P> !RefUnwindSafe for ClientPool<F, P>
impl<F, P> Send for ClientPool<F, P>
impl<F, P> Sync for ClientPool<F, P>
impl<F, P> Unpin for ClientPool<F, P>
impl<F, P> !UnwindSafe for ClientPool<F, P>
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
Mutably borrows from an owned value. Read more