pub struct ClientPool { /* private fields */ }Expand description
A small pool of connections to one service, for callers that hold connections across
calls (a Client carries one request at a time). Connections open lazily through
the caller’s connect source — the same shape Client::call_retrying_over takes,
so host verification stays the caller’s — and a healthy one is reused for the next
call. A client known closed (Client::is_closed) is discarded before a request is
spent on it, and one that closes or times out during a call is discarded after it.
Retries follow the same deadline rules as Client::call_retrying: a retryable
connect failure is retried within policy, and a written request is resubmitted only
on host handoff, or on close/timeout when policy.idempotent says it may run twice.
Implementations§
Source§impl ClientPool
impl ClientPool
Sourcepub fn new<F>(size: usize, connect: F) -> Self
pub fn new<F>(size: usize, connect: F) -> Self
A pool of size connections (at least one), opened by connect, which receives
the per-attempt deadline from the RetryPolicy of each call.
Sourcepub fn discard_all(&self)
pub fn discard_all(&self)
Drop every pooled connection (the host was replaced, so each points at a dead process). The next call on each slot reconnects instead of spending its one attempt on a closed connection.
Sourcepub fn call(&self, method: &str, params: Value) -> Result<Value, ServiceError>
pub fn call(&self, method: &str, params: Value) -> Result<Value, ServiceError>
Call method on a pooled connection under the default RetryPolicy (not
idempotent: a request that may have run is never resent).
Sourcepub fn call_with_policy(
&self,
method: &str,
params: Value,
policy: RetryPolicy,
on_event: &mut dyn FnMut(&Value),
) -> Result<Value, ServiceError>
pub fn call_with_policy( &self, method: &str, params: Value, policy: RetryPolicy, on_event: &mut dyn FnMut(&Value), ) -> Result<Value, ServiceError>
call with an explicit retry policy and event sink. Requests go
through Client::call_large, so oversize requests/results chunk as usual.