pub struct LimitedAttemptCount<P> { /* private fields */ }Expand description
Decorates a resume policy to stop resuming after a certain number of attempts.
§Example
let policy = LimitedAttemptCount::new(AlwaysResume, 3);
assert!(matches!(policy.on_error(&ResumeQuery::new(0), scary_error()), ResumeResult::Continue(_)));
assert!(matches!(policy.on_error(&ResumeQuery::new(1), scary_error()), ResumeResult::Continue(_)));
assert!(matches!(policy.on_error(&ResumeQuery::new(2), scary_error()), ResumeResult::Continue(_)));
assert!(matches!(policy.on_error(&ResumeQuery::new(3), scary_error()), ResumeResult::Exhausted(_)));
use gax::error::{Error, rpc::Code, rpc::Status};
fn scary_error() -> Error {
// ... details omitted ...
}Implementations§
Trait Implementations§
Source§impl<P: Debug> Debug for LimitedAttemptCount<P>
impl<P: Debug> Debug for LimitedAttemptCount<P>
Source§impl<P> ReadResumePolicy for LimitedAttemptCount<P>where
P: ReadResumePolicy,
impl<P> ReadResumePolicy for LimitedAttemptCount<P>where
P: ReadResumePolicy,
Source§fn on_error(&self, status: &ResumeQuery, error: Error) -> ResumeResult
fn on_error(&self, status: &ResumeQuery, error: Error) -> ResumeResult
Determines if the read should continue after an error.
Auto Trait Implementations§
impl<P> Freeze for LimitedAttemptCount<P>where
P: Freeze,
impl<P> RefUnwindSafe for LimitedAttemptCount<P>where
P: RefUnwindSafe,
impl<P> Send for LimitedAttemptCount<P>where
P: Send,
impl<P> Sync for LimitedAttemptCount<P>where
P: Sync,
impl<P> Unpin for LimitedAttemptCount<P>where
P: Unpin,
impl<P> UnwindSafe for LimitedAttemptCount<P>where
P: UnwindSafe,
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> 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::RequestSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ReadResumePolicyExt for Twhere
T: ReadResumePolicy,
impl<T> ReadResumePolicyExt for Twhere
T: ReadResumePolicy,
Source§fn with_attempt_limit(self, maximum_attempts: u32) -> LimitedAttemptCount<Self>
fn with_attempt_limit(self, maximum_attempts: u32) -> LimitedAttemptCount<Self>
Decorates a ReadResumePolicy to limit the number of resume attempts. Read more