Skip to content

Commit

Permalink
Merge pull request #231 from crepererum-oss/crepererum/fix_backoff
Browse files Browse the repository at this point in the history
fix: backoff base & factor
  • Loading branch information
crepererum authored Jul 17, 2024
2 parents e7b13aa + 47aa0bf commit dc7739c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,11 @@ where
F: Fn() -> Fut + Send,
Fut: Future<Output = Result<T, reqwest::Error>> + Send,
{
let strategy = tokio_retry::strategy::ExponentialBackoff::from_millis(500)
// WARNING: The exponential config is somewhat weird. `from_millis(base).factor(factor)` means
// `base^retry * factor`.
// Also see https://github.com/srijs/rust-tokio-retry/issues/22 .
let strategy = tokio_retry::strategy::ExponentialBackoff::from_millis(2)
.factor(500)
.map(tokio_retry::strategy::jitter);

let condition = |e: &reqwest::Error| {
Expand Down
7 changes: 6 additions & 1 deletion src/file_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ pub(crate) async fn write_to_file(content: &[u8], path: &Path) -> Result<()> {
async fn rename(old: &Path, new: &Path) -> Result<(), std::io::Error> {
// some file systems like SMB may not sync immediately and return "not found" shortly after file
// creation
let strategy = tokio_retry::strategy::ExponentialBackoff::from_millis(500)

// WARNING: The exponential config is somewhat weird. `from_millis(base).factor(factor)` means
// `base^retry * factor`.
// Also see https://github.com/srijs/rust-tokio-retry/issues/22 .
let strategy = tokio_retry::strategy::ExponentialBackoff::from_millis(2)
.factor(500)
.map(tokio_retry::strategy::jitter)
.take(10);

Expand Down

0 comments on commit dc7739c

Please sign in to comment.