Skip to main content

Module read_resume_policy

Module read_resume_policy 

Source
Expand description

Defines the read resume policies for Google Cloud Storage.

Even if a read request starts successfully, it may be fail after it starts. For example, the read may be interrupted or become too slow and “stall”. The client library can automatically recover from such errors. The application may want to control what errors are treated as recoverable, and how many failures are tolerated before abandoning the read request.

The traits and types defined in this module allow for such customization.

§Example

let policy = Recommended.with_attempt_limit(3);
assert!(matches!(policy.on_error(&ResumeQuery::new(0), io_error()), ResumeResult::Continue(_)));
assert!(matches!(policy.on_error(&ResumeQuery::new(1), io_error()), ResumeResult::Continue(_)));
assert!(matches!(policy.on_error(&ResumeQuery::new(2), io_error()), ResumeResult::Continue(_)));
assert!(matches!(policy.on_error(&ResumeQuery::new(3), io_error()), ResumeResult::Exhausted(_)));

use google_cloud_gax::error::{Error, rpc::Code, rpc::Status};
fn io_error() -> Error {
   // ... details omitted ...
}

Structs§

AlwaysResume
A resume policy that resumes regardless of the error type.
LimitedAttemptCount
Decorates a resume policy to stop resuming after a certain number of attempts.
NeverResume
A resume policy that never resumes, regardless of the error type.
Recommended
The recommended policy when reading objects from Cloud Storage.
ResumeQuery
The inputs into a resume policy query.

Enums§

ResumeResult
The result of a loop control decision.

Traits§

ReadResumePolicy
Defines the interface to resume policies.
ReadResumePolicyExt
Extension trait for ReadResumePolicy.