Rust

retry

Module

[RetryStrategy]: which failed S3 requests are worth sending again.

Contents

use utopia_storage::s3::retry::RetryStrategy;
Rust
pub struct RetryStrategy

Retries transient S3 failures.

A rejected request (throttled, or never sent) is always retried. One that may have been applied (an internal error, a dropped or timed-out connection) is only retried when replaying it is harmless: not a POST other than CompleteMultipartUpload, and not a conditional write, whose condition the first attempt may already have changed. The XML error code wins over the HTTP status. Waits use exponential backoff with full jitter, or a numeric Retry-After.

Rust
use utopia_storage::s3::{Method, Request, Response, RetryStrategy};

let strategy = RetryStrategy::new(3, 0.5, 20.0).with_randomizer(|| 1.0);
let request = Request { method: Method::Put, url: "https://s3.example.com/a".into(), headers: vec![], body: Default::default() };
assert_eq!(strategy.delay(&request, 1, Some(&Response::new(503)), None), Some(0.5));
assert_eq!(strategy.delay(&request, 1, Some(&Response::new(404)), None), None);
Also implements Default, Debug.