pub struct ClientPool<M: ClientManager> { /* private fields */ }Expand description
A bounded process-local pool of protocol-specific clients.
Implementations§
Source§impl<M: ClientManager> ClientPool<M>
impl<M: ClientManager> ClientPool<M>
Sourcepub fn new(manager: M, options: PoolOptions) -> Result<Self, OptionsError>
pub fn new(manager: M, options: PoolOptions) -> Result<Self, OptionsError>
Construct an empty pool. This performs no network IO.
Sourcepub async fn acquire(
&self,
active_policy: ActiveRequestPolicy,
) -> Result<ClientLease<M>, AcquireError<M::Error>>
pub async fn acquire( &self, active_policy: ActiveRequestPolicy, ) -> Result<ClientLease<M>, AcquireError<M::Error>>
Acquire one client, creating it lazily or waiting for returned capacity.
Sourcepub async fn acquire_cancellable(
&self,
active_policy: ActiveRequestPolicy,
cancellation: &CancellationToken,
) -> Result<ClientLease<M>, AcquireError<M::Error>>
pub async fn acquire_cancellable( &self, active_policy: ActiveRequestPolicy, cancellation: &CancellationToken, ) -> Result<ClientLease<M>, AcquireError<M::Error>>
Acquire one client while also observing caller-owned cancellation.
Sourcepub async fn run(&self, cancellation: CancellationToken) -> Result<(), M::Error>
pub async fn run(&self, cancellation: CancellationToken) -> Result<(), M::Error>
Maintain the declared warm floor until cancellation, then close and drain.
Sourcepub async fn drain(&self)
pub async fn drain(&self)
Stop admission and wait indefinitely for every leased or creating client to end.
Sourcepub fn pause(&self, reason: impl Into<Arc<str>>)
pub fn pause(&self, reason: impl Into<Arc<str>>)
Pause new acquisitions without retiring retained or leased clients.
Sourcepub fn resume(&self) -> bool
pub fn resume(&self) -> bool
Resume a policy-paused pool. Closing and draining are irreversible.
Sourcepub fn apply(&self, directive: PoolDirective)
pub fn apply(&self, directive: PoolDirective)
Apply a protocol-neutral admission consequence.
Sourcepub fn cancel_active(&self) -> bool
pub fn cancel_active(&self) -> bool
Explicitly cancel work holding a lease after admission has stopped.
Graceful Self::drain never calls this. The runtime may call it only
when its own policy has decided that active requests should no longer
be preserved. Calling it while admission is open has no effect.