#[non_exhaustive]pub struct RetryConfigBuilder { /* private fields */ }
Expand description
Builder for RetryConfig
.
Implementations§
Source§impl RetryConfigBuilder
impl RetryConfigBuilder
Sourcepub fn new() -> RetryConfigBuilder
pub fn new() -> RetryConfigBuilder
Creates a new builder.
Sourcepub fn set_mode(
&mut self,
retry_mode: Option<RetryMode>,
) -> &mut RetryConfigBuilder
pub fn set_mode( &mut self, retry_mode: Option<RetryMode>, ) -> &mut RetryConfigBuilder
Sets the retry mode.
Sourcepub fn mode(self, mode: RetryMode) -> RetryConfigBuilder
pub fn mode(self, mode: RetryMode) -> RetryConfigBuilder
Sets the retry mode.
Sourcepub fn reconnect_mode(self, reconnect_mode: ReconnectMode) -> RetryConfigBuilder
pub fn reconnect_mode(self, reconnect_mode: ReconnectMode) -> RetryConfigBuilder
Set the ReconnectMode
for the retry strategy
By default, when a transient error is encountered, the connection in use will be poisoned. This prevents reusing a connection to a potentially bad host but may increase the load on the server.
This behavior can be disabled by setting ReconnectMode::ReuseAllConnections
instead.
Sourcepub fn set_reconnect_mode(
&mut self,
reconnect_mode: Option<ReconnectMode>,
) -> &mut RetryConfigBuilder
pub fn set_reconnect_mode( &mut self, reconnect_mode: Option<ReconnectMode>, ) -> &mut RetryConfigBuilder
Set the ReconnectMode
for the retry strategy
By default, when a transient error is encountered, the connection in use will be poisoned. This prevents reusing a connection to a potentially bad host but may increase the load on the server.
This behavior can be disabled by setting ReconnectMode::ReuseAllConnections
instead.
Sourcepub fn set_max_attempts(
&mut self,
max_attempts: Option<u32>,
) -> &mut RetryConfigBuilder
pub fn set_max_attempts( &mut self, max_attempts: Option<u32>, ) -> &mut RetryConfigBuilder
Sets the max attempts. This value must be greater than zero.
Sourcepub fn max_attempts(self, max_attempts: u32) -> RetryConfigBuilder
pub fn max_attempts(self, max_attempts: u32) -> RetryConfigBuilder
Sets the max attempts. This value must be greater than zero.
Sourcepub fn set_initial_backoff(
&mut self,
initial_backoff: Option<Duration>,
) -> &mut RetryConfigBuilder
pub fn set_initial_backoff( &mut self, initial_backoff: Option<Duration>, ) -> &mut RetryConfigBuilder
Set the initial_backoff duration. This duration should be non-zero.
Sourcepub fn initial_backoff(self, initial_backoff: Duration) -> RetryConfigBuilder
pub fn initial_backoff(self, initial_backoff: Duration) -> RetryConfigBuilder
Set the initial_backoff duration. This duration should be non-zero.
Sourcepub fn set_max_backoff(
&mut self,
max_backoff: Option<Duration>,
) -> &mut RetryConfigBuilder
pub fn set_max_backoff( &mut self, max_backoff: Option<Duration>, ) -> &mut RetryConfigBuilder
Set the max_backoff duration. This duration should be non-zero.
Sourcepub fn max_backoff(self, max_backoff: Duration) -> RetryConfigBuilder
pub fn max_backoff(self, max_backoff: Duration) -> RetryConfigBuilder
Set the max_backoff duration. This duration should be non-zero.
Sourcepub fn take_unset_from(self, other: RetryConfigBuilder) -> RetryConfigBuilder
pub fn take_unset_from(self, other: RetryConfigBuilder) -> RetryConfigBuilder
Merge two builders together. Values from other
will only be used as a fallback for values
from self
Useful for merging configs from different sources together when you want to
handle “precedence” per value instead of at the config level
§Example
let a = RetryConfigBuilder::new().max_attempts(1);
let b = RetryConfigBuilder::new().max_attempts(5).mode(RetryMode::Adaptive);
let retry_config = a.take_unset_from(b).build();
// A's value take precedence over B's value
assert_eq!(retry_config.max_attempts(), 1);
// A never set a retry mode so B's value was used
assert_eq!(retry_config.mode(), RetryMode::Adaptive);
Sourcepub fn build(self) -> RetryConfig
pub fn build(self) -> RetryConfig
Builds a RetryConfig
.
Trait Implementations§
Source§impl Clone for RetryConfigBuilder
impl Clone for RetryConfigBuilder
Source§fn clone(&self) -> RetryConfigBuilder
fn clone(&self) -> RetryConfigBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for RetryConfigBuilder
impl Debug for RetryConfigBuilder
Source§impl Default for RetryConfigBuilder
impl Default for RetryConfigBuilder
Source§fn default() -> RetryConfigBuilder
fn default() -> RetryConfigBuilder
Source§impl PartialEq for RetryConfigBuilder
impl PartialEq for RetryConfigBuilder
impl StructuralPartialEq for RetryConfigBuilder
Auto Trait Implementations§
impl Freeze for RetryConfigBuilder
impl RefUnwindSafe for RetryConfigBuilder
impl Send for RetryConfigBuilder
impl Sync for RetryConfigBuilder
impl Unpin for RetryConfigBuilder
impl UnwindSafe for RetryConfigBuilder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more