Skip to main content

ClientPool

Struct ClientPool 

Source
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>

Source

pub fn new(manager: M, options: PoolOptions) -> Result<Self, OptionsError>

Construct an empty pool. This performs no network IO.

Source

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.

Source

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.

Source

pub async fn run(&self, cancellation: CancellationToken) -> Result<(), M::Error>

Maintain the declared warm floor until cancellation, then close and drain.

Source

pub fn close(&self)

Reject new acquisitions and drop retained idle clients.

Source

pub async fn drain(&self)

Stop admission and wait indefinitely for every leased or creating client to end.

Source

pub fn pause(&self, reason: impl Into<Arc<str>>)

Pause new acquisitions without retiring retained or leased clients.

Source

pub fn resume(&self) -> bool

Resume a policy-paused pool. Closing and draining are irreversible.

Source

pub fn apply(&self, directive: PoolDirective)

Apply a protocol-neutral admission consequence.

Source

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.

Source

pub fn stats(&self) -> PoolStats

Trait Implementations§

Source§

impl<M: ClientManager> Clone for ClientPool<M>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<M> Freeze for ClientPool<M>
where Arc<Inner<M>>: Freeze,

§

impl<M> RefUnwindSafe for ClientPool<M>
where Arc<Inner<M>>: RefUnwindSafe,

§

impl<M> Send for ClientPool<M>
where Arc<Inner<M>>: Send,

§

impl<M> Sync for ClientPool<M>
where Arc<Inner<M>>: Sync,

§

impl<M> Unpin for ClientPool<M>
where Arc<Inner<M>>: Unpin,

§

impl<M> UnsafeUnpin for ClientPool<M>
where Arc<Inner<M>>: UnsafeUnpin,

§

impl<M> UnwindSafe for ClientPool<M>
where Arc<Inner<M>>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.