pub struct RetryLoop { /* private fields */ }Expand description
Drives the retry loop for a single RPC call.
Create one per call, then call advance after every failure.
ⓘ
let mut rl = RetryLoop::new(Arc::clone(&self.inner.retry_policy));
loop {
match self.do_rpc_call(req).await {
Ok(body) => return Ok(body),
Err(e) => rl.advance(e).await?,
}
}advance either:
- sleeps the required duration and returns
Ok(())→ caller should retry, or - returns
Err(e)→ caller should propagate.
This is the single source of truth; previously the same loop was
copy-pasted into rpc_call_raw, rpc_write, and the reconnect path.
Implementations§
Source§impl RetryLoop
impl RetryLoop
pub fn new(policy: Arc<dyn RetryPolicy>) -> Self
Sourcepub async fn advance(
&mut self,
err: InvocationError,
) -> Result<(), InvocationError>
pub async fn advance( &mut self, err: InvocationError, ) -> Result<(), InvocationError>
Record a failure and either sleep+return-Ok (retry) or return-Err (give up).
Mutates self to track cumulative state across retries.
Auto Trait Implementations§
impl Freeze for RetryLoop
impl !RefUnwindSafe for RetryLoop
impl Send for RetryLoop
impl Sync for RetryLoop
impl Unpin for RetryLoop
impl UnsafeUnpin for RetryLoop
impl !UnwindSafe for RetryLoop
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
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>
Converts
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>
Converts
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