pub struct RetryBudget { /* private fields */ }Expand description
A budget that limits how many times an operation may be retried, and for how long in total.
Implementations§
Source§impl RetryBudget
impl RetryBudget
Sourcepub fn new(
max_attempts: u32,
time_budget: Duration,
strategy: BackoffStrategy,
) -> Self
pub fn new( max_attempts: u32, time_budget: Duration, strategy: BackoffStrategy, ) -> Self
Create a new RetryBudget.
Sourcepub fn next_delay(&self, attempt: u32) -> Option<Duration>
pub fn next_delay(&self, attempt: u32) -> Option<Duration>
Compute the delay before attempt number attempt (0-indexed).
Returns None if the budget is exhausted.
Sourcepub fn can_retry(&self, elapsed: Duration) -> bool
pub fn can_retry(&self, elapsed: Duration) -> bool
Returns true if another attempt is permitted given that elapsed
time has already been spent.
Sourcepub fn record_attempt(
&self,
success: bool,
duration_ms: u64,
error: Option<String>,
)
pub fn record_attempt( &self, success: bool, duration_ms: u64, error: Option<String>, )
Record the outcome of an attempt.
Sourcepub fn remaining_attempts(&self) -> u32
pub fn remaining_attempts(&self) -> u32
Return the number of attempts still available.
Sourcepub fn remaining_time(&self, elapsed: Duration) -> Option<Duration>
pub fn remaining_time(&self, elapsed: Duration) -> Option<Duration>
Return the remaining time budget given that elapsed has already been
consumed. Returns None if the budget is already exhausted.
Sourcepub fn budget_report(&self) -> BudgetReport
pub fn budget_report(&self) -> BudgetReport
Produce a summary report of the current budget state.
Auto Trait Implementations§
impl !Freeze for RetryBudget
impl RefUnwindSafe for RetryBudget
impl Send for RetryBudget
impl Sync for RetryBudget
impl Unpin for RetryBudget
impl UnsafeUnpin for RetryBudget
impl UnwindSafe for RetryBudget
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request