failsafe-lib / failsafe

Fault tolerance and resilience patterns for the JVM
https://failsafe.dev
Apache License 2.0
4.2k stars 297 forks source link

Support staggered/hedged retries #291

Open timothybasanov opened 3 years ago

timothybasanov commented 3 years ago

Not a Contribution.

Currently Failsafe only allows to make a single retry at a time. Sometimes it's beneficial to make several retries at the same time and hope that one of them would be successful.

It would be nice if it would be possible to configure retry and timeout policies in such a way that:

  1. A first attempt starts with a timeout of 100ms
  2. After 10ms pass, a second attempt starts with a timeout of 90ms
  3. After another 20ms pass, a third attempt starts with a timeout of 70ms
  4. When any of the attempts succeed, results are returned back immediately
  5. All executions still in-flight are cancelled

It would be super helpful to have an attempt-specific timeout in ContextualSupplier, so that some special can be done with it on the application level.

timothybasanov commented 3 years ago

Not a Contribution.

To better align with #159, mentioning hedged requests as they are seemingly are a different name/flavor for staggered requests.