reqwest-middleware icon indicating copy to clipboard operation
reqwest-middleware copied to clipboard

RetryDecision is not exposed from reqwest_retry

Open emilbonnek opened this issue 1 year ago • 2 comments

Bug description

Currently, it is not possible to create custom RetryPolicy implementations because the RetryDecision type is not exposed by the crate. So its a bit all or nothing and I can't create a policy that conditionally retry requests.

To Reproduce

This code will not work because the compiler complains about reqwest_retry::RetryDecision not exisiting.

impl reqwest_retry::RetryPolicy for CustomRetryPolicy {
  fn should_retry(&self, attempt: u32) -> reqwest_retry::RetryDecision {
    // Some custom logic determining if the request should be retried.
  }
}

Expected behavior

I expected the above to work.

Environment

  • OS: Windows
  • Rust version: 1.67.1

Additional context

I am new to Rust, so please let me know if I am misunderstanding something or if I am using the crate incorrectly.

emilbonnek avatar Mar 28 '23 22:03 emilbonnek

Oh, you're right. For now you can work around this, the trait is re-exported from retry-policies, so you can add that to your deps and import it from there instead.

We should re-export RetryDecision as well though, I see no reason not to.

tl-rodrigo-gryzinski avatar Mar 31 '23 09:03 tl-rodrigo-gryzinski

Thanks, I am okay with just using it from retry-policies. I didn't even know that was an option until now.

I'll leave this open in case you want to close it with a PR.

emilbonnek avatar Apr 06 '23 20:04 emilbonnek