Skip to content

Commit

Permalink
7.0.1 (#184)
Browse files Browse the repository at this point in the history
* fix: don't panic when jitter is 0
  • Loading branch information
JulianKovacek authored Nov 17, 2023
1 parent 76d2be2 commit aa7fc02
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,11 @@ where
}

pub fn add_jitter(delay: u64, jitter: u32) -> u64 {
delay.saturating_add(rand::thread_rng().gen_range(0 .. jitter as u64))
if jitter == 0 {
delay
} else {
delay.saturating_add(rand::thread_rng().gen_range(0 .. jitter as u64))
}
}

pub fn into_redis_map<I, K, V>(mut iter: I) -> Result<HashMap<RedisKey, RedisValue>, RedisError>
Expand Down Expand Up @@ -832,6 +836,11 @@ mod tests {
RedisValue::Array(v)
}

#[test]
fn should_not_panic_with_zero_jitter() {
assert_eq!(add_jitter(10, 0), 10);
}

#[test]
fn should_flatten_xread_example() {
// 127.0.0.1:6379> xread count 2 streams foo bar 1643479648480-0 1643479834990-0
Expand Down

0 comments on commit aa7fc02

Please sign in to comment.