Struct opendal::layers::RetryLayer
source · pub struct RetryLayer(_);
Expand description
Add retry for temporary failed operations.
Notes
This layer will retry failed operations when Error::is_temporary
returns true. If operation still failed, this layer will set error to
Persistent
which means error has been retried.
write
and blocking_write
don’t support retry so far, visit this issue for more details.
Examples
use anyhow::Result;
use opendal::layers::RetryLayer;
use opendal::services;
use opendal::Operator;
use opendal::Scheme;
let _ = Operator::new(services::Memory::default())
.expect("must init")
.layer(RetryLayer::new())
.finish();
Implementations§
source§impl RetryLayer
impl RetryLayer
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new retry layer.
Examples
use anyhow::Result;
use opendal::layers::RetryLayer;
use opendal::services;
use opendal::Operator;
use opendal::Scheme;
let _ = Operator::new(services::Memory::default())
.expect("must init")
.layer(RetryLayer::new());
sourcepub fn with_jitter(self) -> Self
pub fn with_jitter(self) -> Self
Set jitter of current backoff.
If jitter is enabled, ExponentialBackoff will add a random jitter in `[0, min_delay) to current delay.
sourcepub fn with_factor(self, factor: f32) -> Self
pub fn with_factor(self, factor: f32) -> Self
sourcepub fn with_min_delay(self, min_delay: Duration) -> Self
pub fn with_min_delay(self, min_delay: Duration) -> Self
Set min_delay of current backoff.
sourcepub fn with_max_delay(self, max_delay: Duration) -> Self
pub fn with_max_delay(self, max_delay: Duration) -> Self
Set max_delay of current backoff.
Delay will not increasing if current delay is larger than max_delay.
sourcepub fn with_max_times(self, max_times: usize) -> Self
pub fn with_max_times(self, max_times: usize) -> Self
Set max_times of current backoff.
Backoff will return None
if max times is reaching.
Trait Implementations§
source§impl Default for RetryLayer
impl Default for RetryLayer
source§fn default() -> RetryLayer
fn default() -> RetryLayer
Returns the “default value” for a type. Read more
source§impl<A: Accessor> Layer<A> for RetryLayer
impl<A: Accessor> Layer<A> for RetryLayer
§type LayeredAccessor = RetryAccessor<A>
type LayeredAccessor = RetryAccessor<A>
The layered accessor that return by this layer.
source§fn layer(&self, inner: A) -> Self::LayeredAccessor
fn layer(&self, inner: A) -> Self::LayeredAccessor
Intercept the operations on the underlying storage.