pub trait ReadResumePolicyExt: Sized {
// Provided method
fn with_attempt_limit(
self,
maximum_attempts: u32,
) -> LimitedAttemptCount<Self> { ... }
}Expand description
Extension trait for ReadResumePolicy.
Provided Methods§
Sourcefn 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.
This policy decorates an inner policy and limits the total number of
attempts. Note that on_error() is not called before the initial
(non-retry) attempt. Therefore, setting the maximum number of attempts
to 0 or 1 results in no retry attempts.
The policy passes through the results from the inner policy as long as
attempt_count < maximum_attempts. Once the maximum number of attempts
is reached, the policy returns Exhausted if the
inner policy returns Continue.
§Example
let policy = Recommended.with_attempt_limit(3);
assert!(matches!(policy.on_error(&ResumeQuery::new(0), transient_error()), ResumeResult::Continue(_)));
assert!(matches!(policy.on_error(&ResumeQuery::new(1), transient_error()), ResumeResult::Continue(_)));
assert!(matches!(policy.on_error(&ResumeQuery::new(2), transient_error()), ResumeResult::Continue(_)));
assert!(matches!(policy.on_error(&ResumeQuery::new(3), transient_error()), ResumeResult::Exhausted(_)));
use google_cloud_gax::error::{Error, rpc::Code, rpc::Status};
fn transient_error() -> Error {
// ... details omitted ...
}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".