Skip to main content

retry_transient_http

Function retry_transient_http 

Source
pub async fn retry_transient_http<F, Fut>(build_and_send: F) -> Result<Response>
where F: FnMut() -> Fut, Fut: Future<Output = Result<Response>>,
Expand description

Retry a closure whose output is Result<reqwest::Response> whenever the response was a transient upstream failure (5xx / 429 / connection failed). Returns the first non-transient response, or the last result after attempts are exhausted.

The closure takes nothing and must rebuild the request internally because reqwest::RequestBuilder::send consumes the builder — so each attempt needs a fresh one.