pub struct FailoverPool<F, P>where
F: ClientFacts,
P: ClientTransport,{ /* 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>where
F: ClientFacts,
P: ClientTransport,
impl<F, P> FailoverPool<F, P>where
F: ClientFacts,
P: ClientTransport,
Sourcepub fn new(
facts: Arc<F>,
rt: Option<&<P::RT as AsyncRuntime>::Exec>,
addrs: Vec<String>,
stateless: bool,
retry_limit: usize,
pool_channel_size: usize,
) -> Self
pub fn new( facts: Arc<F>, rt: Option<&<P::RT as AsyncRuntime>::Exec>, addrs: Vec<String>, stateless: bool, retry_limit: usize, pool_channel_size: usize, ) -> Self
Initiate the pool with multiple addresses.
§Argument
rt: When we are in orb async context, just pass None, otherwise (in thread context), pass the AsyncRuntime::Exec.stateless: When true, all addresses in the pool will be selected with equal chance (round-robin); When false, the leader address will always be picked unless error happens.
Sourcepub fn get_retry_limit(&self) -> usize
pub fn get_retry_limit(&self) -> usize
Get the retry limit for redirect operations
Sourcepub async fn resubmit(
&self,
task: F::Task,
addr_or_retry: Result<String, usize>,
retry_count: usize,
max_retries: Option<usize>,
)where
F::Task: ClientTask,
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)
pub fn update_addrs(&self, addrs: Vec<String>)
Trait Implementations§
Source§impl<F, P> ClientCaller for FailoverPool<F, P>where
F: ClientFacts,
P: ClientTransport,
impl<F, P> ClientCaller for FailoverPool<F, P>where
F: ClientFacts,
P: ClientTransport,
Source§impl<F, P> ClientCallerBlocking for FailoverPool<F, P>where
F: ClientFacts,
P: ClientTransport,
impl<F, P> ClientCallerBlocking for FailoverPool<F, P>where
F: ClientFacts,
P: ClientTransport,
Source§impl<F, P> Clone for FailoverPool<F, P>where
F: ClientFacts,
P: ClientTransport,
impl<F, P> Clone for FailoverPool<F, P>where
F: ClientFacts,
P: ClientTransport,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more