Conversation
backon/src/lib.rs
Outdated
| //! | ||
| //! - `tokio-sleep`: Utilizes [`TokioSleeper`] within a Tokio context in non-wasm32 environments. | ||
| //! - `gloo-timers-sleep`: Utilizes [`GlooTimersSleep`] to pause in wasm32 environments. | ||
| //! Currently, BackON has 2 built-in `Sleeper` implementations for different environments, |
There was a problem hiding this comment.
Should be 3, we have std-blocking-sleep for blocking context.
There was a problem hiding this comment.
Added the BlockingSleeper to the table.
backon/src/lib.rs
Outdated
| //! ```rust,ignore | ||
| //! use std::time::Duration; | ||
| //! use backon::Sleeper; | ||
| //! use monoio::time::sleep; |
There was a problem hiding this comment.
I don't want to use Monoio as an example here. Let's just implement a function that prints "Hello, World!" and then returns Ready
backon/src/lib.rs
Outdated
| //! | ||
| //! ## The empty `Sleeper` | ||
| //! | ||
| //! If neither feature is enabled nor a custom implementation is provided, BackON will fallback to the empty sleeper. This will cause a panic in the `debug` profile and do nothing in the `release` profile. |
There was a problem hiding this comment.
This is out-of-date now. We will raise a build error now.
|
Would you like to also provide an real example in |
Sure, will address the feedback tomorrow:) |
Done |
| //! | ||
| //! Retry in BackON requires an implementation for sleeping. BackON will accept a [`Sleeper`] to pause for a specified duration. | ||
| //! Retry in BackON requires an implementation for sleeping, such an implementation | ||
| //! is called a Sleeper, it will implement [`Sleeper`] or [`BlockingSleeper`] depending |
There was a problem hiding this comment.
such an implementation is called a Sleeper, it will implement [
Sleeper] or [BlockingSleeper] depending on if it is going to be used in an asynchronous context.
I try to differentiate "Sleeper" from "`Sleeper`" (quoted with backticks), the former is a general concept, which can be a "`Sleeper`" or "`BlockingSleeper`", while the later is just the async Sleeper trait.
What does this PR do
Adds an example for user-provided sleeper implementation.
Closes #129