RetryPolicy

Trait RetryPolicy 

Source
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§

Source

fn should_retry(&self, retried: u32, op: OtsOp, ots_error: &OtsError) -> bool

是否需要重试。参数分别表示重试次数、操作和发生的错误

Source

fn delay_ms(&self) -> u32

如果需要重试,重试之前让线程等待的时间

Source

fn clone_box(&self) -> Box<dyn RetryPolicy>

需要自行实现克隆逻辑。一般来说就是需要重置一些记录参数,为下一次全新的请求做准备

Trait Implementations§

Source§

impl Clone for Box<dyn RetryPolicy>

Source§

fn clone(&self) -> Box<dyn RetryPolicy>

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

Implementors§