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: &P::RT,
addrs: Vec<String>,
stateless: bool,
retry_limit: usize,
pool_channel_size: usize,
) -> Self
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.
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)