pub trait RetryPolicy:
Debug
+ Send
+ Sync {
// Required methods
fn should_retry(
&self,
retried: u32,
op: OtsOp,
ots_error: &OtsError,
) -> bool;
fn delay_ms(&self) -> u32;
fn clone_box(&self) -> Box<dyn RetryPolicy>;
}Expand description
重试策略。需要注意的是 clone_box 方法中用来重置策略的状态数据(如果有的话)
Required Methods§
Sourcefn should_retry(&self, retried: u32, op: OtsOp, ots_error: &OtsError) -> bool
fn should_retry(&self, retried: u32, op: OtsOp, ots_error: &OtsError) -> bool
是否需要重试。参数分别表示重试次数、操作和发生的错误
Sourcefn clone_box(&self) -> Box<dyn RetryPolicy>
fn clone_box(&self) -> Box<dyn RetryPolicy>
需要自行实现克隆逻辑。一般来说就是需要重置一些记录参数,为下一次全新的请求做准备
Trait Implementations§
Source§impl Clone for Box<dyn RetryPolicy>
impl Clone for Box<dyn RetryPolicy>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more