Skip to main content

FailoverPool

Struct FailoverPool 

Source
pub struct FailoverPool<F, P>{ /* private fields */ }
Expand description

A pool supports failover to multiple address with bias or round_robin strategy

Supports async and blocking context.

Only retry RpcIntErr that less than RpcIntErr::Method, currently ignore custom error due to complexity of generic. (If you need to custom failover logic, copy the code and impl your own pool.)

Implementations§

Source§

impl<F, P> FailoverPool<F, P>

Source

pub fn new( facts: Arc<F>, addrs: Vec<String>, round_robin: bool, retry_limit: usize, pool_channel_size: usize, ) -> Self

Initate the pool with multiple address. When round_robin == true, all address in the pool will be select with equal chanced; When round_robin == false, the first address will always be pick unless error happens.

Source

pub fn update_addrs(&self, addrs: Vec<String>)

Trait Implementations§

Source§

impl<F, P> ClientCaller for FailoverPool<F, P>

Source§

type Facts = F

Source§

async fn send_req(&self, task: F::Task)

Source§

impl<F, P> ClientCallerBlocking for FailoverPool<F, P>

Source§

type Facts = F

Source§

fn send_req_blocking(&self, task: F::Task)

Source§

impl<F, P> Clone for FailoverPool<F, P>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<F, P> Freeze for FailoverPool<F, P>

§

impl<F, P> !RefUnwindSafe for FailoverPool<F, P>

§

impl<F, P> Send for FailoverPool<F, P>

§

impl<F, P> Sync for FailoverPool<F, P>

§

impl<F, P> Unpin for FailoverPool<F, P>

§

impl<F, P> UnsafeUnpin for FailoverPool<F, P>

§

impl<F, P> !UnwindSafe for FailoverPool<F, P>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.