-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: document custom Sleeper impl #147
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be 3
, we have std-blocking-sleep
for blocking context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is out-of-date now. We will raise a build error now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
Would you like to also provide an real example in |
Sure, will address the feedback tomorrow:) |
Done |
@@ -31,16 +31,53 @@ | |||
//! | |||
//! # Sleep | |||
//! | |||
//! 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
What does this PR do
Adds an example for user-provided sleeper implementation.
Closes #129