@@ -11,7 +11,7 @@ use linkerd_error::Error;
11
11
use linkerd_metrics:: prom;
12
12
use linkerd_pool:: Pool ;
13
13
use linkerd_stack:: { NewService , Service } ;
14
- use rand:: { rngs:: SmallRng , thread_rng , Rng , SeedableRng } ;
14
+ use rand:: { rngs:: SmallRng , Rng , SeedableRng } ;
15
15
use std:: {
16
16
collections:: hash_map:: Entry ,
17
17
net:: SocketAddr ,
76
76
S :: Metric : std:: fmt:: Debug ,
77
77
{
78
78
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 ( ) ) ;
80
80
Self {
81
81
rng,
82
82
metrics,
@@ -120,8 +120,8 @@ fn gen_pair(rng: &mut SmallRng, len: usize) -> (usize, usize) {
120
120
debug_assert ! ( len >= 2 , "must have at least two endpoints" ) ;
121
121
// Get two distinct random indexes (in a random order) and
122
122
// 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 ) ) ;
125
125
if bidx >= aidx {
126
126
bidx += 1 ;
127
127
}
@@ -376,7 +376,7 @@ mod tests {
376
376
if len < 2 {
377
377
return quickcheck:: TestResult :: discard( ) ;
378
378
}
379
- let mut rng = SmallRng :: from_rng( rand:: thread_rng ( ) ) . expect ( "rng" ) ;
379
+ let mut rng = SmallRng :: from_rng( & mut rand:: rng ( ) ) ;
380
380
let ( aidx, bidx) = gen_pair( & mut rng, len) ;
381
381
quickcheck:: TestResult :: from_bool( aidx != bidx)
382
382
}
0 commit comments