Skip to content

Commit 39283dc

Browse files
committed
chore(pool/p2c): address rand breaking changes
Signed-off-by: katelyn martin <[email protected]>
1 parent 00ace22 commit 39283dc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

linkerd/pool/p2c/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use linkerd_error::Error;
1111
use linkerd_metrics::prom;
1212
use linkerd_pool::Pool;
1313
use linkerd_stack::{NewService, Service};
14-
use rand::{rngs::SmallRng, thread_rng, Rng, SeedableRng};
14+
use rand::{rngs::SmallRng, Rng, SeedableRng};
1515
use std::{
1616
collections::hash_map::Entry,
1717
net::SocketAddr,
@@ -76,7 +76,7 @@ where
7676
S::Metric: std::fmt::Debug,
7777
{
7878
pub fn new(metrics: P2cMetrics, new_endpoint: N) -> Self {
79-
let rng = SmallRng::from_rng(&mut thread_rng()).expect("RNG must be seeded");
79+
let rng = SmallRng::from_rng(&mut rand::rng());
8080
Self {
8181
rng,
8282
metrics,
@@ -120,8 +120,8 @@ fn gen_pair(rng: &mut SmallRng, len: usize) -> (usize, usize) {
120120
debug_assert!(len >= 2, "must have at least two endpoints");
121121
// Get two distinct random indexes (in a random order) and
122122
// compare the loads of the service at each index.
123-
let aidx = rng.gen_range(0..len);
124-
let mut bidx = rng.gen_range(0..(len - 1));
123+
let aidx = rng.random_range(0..len);
124+
let mut bidx = rng.random_range(0..(len - 1));
125125
if bidx >= aidx {
126126
bidx += 1;
127127
}
@@ -376,7 +376,7 @@ mod tests {
376376
if len < 2 {
377377
return quickcheck::TestResult::discard();
378378
}
379-
let mut rng = SmallRng::from_rng(rand::thread_rng()).expect("rng");
379+
let mut rng = SmallRng::from_rng(&mut rand::rng());
380380
let (aidx, bidx) = gen_pair(&mut rng, len);
381381
quickcheck::TestResult::from_bool(aidx != bidx)
382382
}

0 commit comments

Comments
 (0)