http-rs / surf

Fast and friendly HTTP client framework for async Rust
https://docs.rs/surf
Apache License 2.0
1.46k stars 119 forks source link

Retry request feature #169

Open xpepermint opened 4 years ago

xpepermint commented 4 years ago

It would be great to have a retry mechanic included.

zkat commented 4 years ago

This could probably be implemented as a middleware, using https://crates.io/crates/backoff/

Fishrock123 commented 4 years ago

The correct solution here is a middleware, although that may presently be a bit challenging.

https://github.com/http-rs/surf/issues/192 proposes things related to this, namely potential middleware re-use and non-consumption of surf::Request.

Edit: I do not believe this is currently possible, see https://github.com/http-rs/surf/issues/196

mchlrhw commented 4 years ago

@Fishrock123 https://github.com/ihrwein/backoff/pull/13 has now merged, so this should be achievable using something similar to the code snippets in the comments of that PR.