ihrwein / backoff

Exponential backoff and retry for Rust.
https://github.com/ihrwein/backoff
Apache License 2.0
306 stars 37 forks source link

Make the future::retry functions generic over the sleeper #25

Closed coolreader18 closed 3 years ago

coolreader18 commented 3 years ago

I realized that the conditional compilation for fn sleep() -> Sleep in async.rs could be represented as a trait, so I did this. I'm not too sure about the names.

This allows for accessing both the async_std and tokio versions of the retry functions if so desired, and also lets you implement your own sleeper if you use some other runtime.

ihrwein commented 3 years ago

Hello @coolreader18 ! Thanks for your contribution again.

I like that sleeper direction, it's better for testing purposes too.

Let me merge your PR but I won't issue a release right away. This will deserve a 0.3 version and I might bundle in some more changes into a release (mainly more deps updates and simplifications).

coolreader18 commented 3 years ago

Alright, sounds good!