pub struct ConnPool<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 ConnPool 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: ClientFacts, P: ClientTransport> ConnPool<F, P>
impl<F: ClientFacts, P: ClientTransport> ConnPool<F, P>
Sourcepub fn new(
facts: Arc<F>,
rt: Option<&<P::RT as AsyncRuntime>::Exec>,
addr: &str,
channel_size: usize,
) -> Self
pub fn new( facts: Arc<F>, rt: Option<&<P::RT as AsyncRuntime>::Exec>, addr: &str, channel_size: usize, ) -> Self
§Argument
rt: When we are in orb async context, just pass None, otherwise (in thread context), pass the AsyncRuntime::Exec.
pub fn is_healthy(&self) -> bool
pub fn get_addr(&self) -> &str
pub async fn send_req(&self, task: F::Task)
pub fn send_req_blocking(&self, task: F::Task)
Trait Implementations§
Source§impl<F: ClientFacts, P: ClientTransport> ClientCaller for ConnPool<F, P>
impl<F: ClientFacts, P: ClientTransport> ClientCaller for ConnPool<F, P>
Source§impl<F: ClientFacts, P: ClientTransport> ClientCallerBlocking for ConnPool<F, P>
impl<F: ClientFacts, P: ClientTransport> ClientCallerBlocking for ConnPool<F, P>
Source§impl<F: ClientFacts, P: ClientTransport> Clone for ConnPool<F, P>
impl<F: ClientFacts, P: ClientTransport> Clone for ConnPool<F, P>
Auto Trait Implementations§
impl<F, P> !Freeze for ConnPool<F, P>
impl<F, P> !RefUnwindSafe for ConnPool<F, P>
impl<F, P> Send for ConnPool<F, P>
impl<F, P> Sync for ConnPool<F, P>
impl<F, P> Unpin for ConnPool<F, P>
impl<F, P> UnsafeUnpin for ConnPool<F, P>
impl<F, P> !UnwindSafe for ConnPool<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