Skip to main content

FailoverPool

Struct FailoverPool 

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

A pool supports failover to multiple addresses with stateless (round-robin) or stateful (leader-based) 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>, rt: &P::RT, addrs: Vec<String>, stateless: bool, retry_limit: usize, pool_channel_size: usize, ) -> Self

Initiate the pool with multiple addresses. When stateless == true, all addresses in the pool will be selected with equal chance (round-robin); When stateless == false, the leader address will always be picked unless error happens.

Source

pub fn get_retry_limit(&self) -> usize

Get the retry limit for redirect operations

Source

pub async fn resubmit( &self, task: F::Task, addr_or_retry: Result<String, usize>, retry_count: usize, max_retries: Option<usize>, )
where F::Task: ClientTask,

Resubmit a request for retry with optional specific address. Called by APIClientCaller when should_failover returns Ok(_).

NOTE: max_retries is currently not used yet (TODO api interface)

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§

fn get_codec(&self) -> <Self::Facts as ClientFacts>::Codec

Source§

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

Source§

type Facts = F

Source§

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

Source§

fn get_codec(&self) -> <Self::Facts as ClientFacts>::Codec

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.