Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
fredclausen committed Jan 27, 2025
1 parent 394016b commit aead622
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 20 deletions.
78 changes: 62 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sdre-stubborn-io"
version = "0.5.15"
version = "0.6.0"
authors = ["David Raifaizen <[email protected]>", "Fred Clausen"]
edition = "2021"
description = "Forked from https://github.com/craftytrickster/stubborn-io. io traits/structs that automatically recover from potential disconnections/interruptions."
Expand All @@ -13,7 +13,7 @@ readme = "README.md"
[dependencies]
tokio = { version = "1.43.0", features = ["time", "net"] }
log = "0.4.25"
rand = "0.8.5"
rand = "0.9.0"

[dev-dependencies]
tokio = { version = "1.43.0", features = ["macros", "rt", "fs", "io-util"] }
Expand Down
4 changes: 2 additions & 2 deletions src/strategies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl IntoIterator for ExpBackoffStrategy {
let init = self.min.as_secs_f64();
let rng = match self.seed {
Some(seed) => StdRng::seed_from_u64(seed),
None => StdRng::from_entropy(),
None => StdRng::from_os_rng(),
};

ExpBackoffIter {
Expand All @@ -97,7 +97,7 @@ impl Iterator for ExpBackoffIter {

fn next(&mut self) -> Option<Self::Item> {
let base = self.init * self.strategy.factor.powf(self.pow as f64);
let jitter = base * self.strategy.jitter * (self.rng.gen::<f64>() * 2. - 1.);
let jitter = base * self.strategy.jitter * (self.rng.random::<f64>() * 2. - 1.);
let current = Duration::from_secs_f64(base + jitter);
self.pow += 1;
match self.strategy.max {
Expand Down

0 comments on commit aead622

Please sign in to comment.