File tree 3 files changed +5
-6
lines changed
3 files changed +5
-6
lines changed Original file line number Diff line number Diff line change 1
1
use ahash:: { HashMap , HashMapExt } ;
2
2
use rand:: {
3
- distributions :: { WeightedError , WeightedIndex } ,
3
+ distr :: weighted :: { Error as WeightedError , WeightedIndex } ,
4
4
prelude:: Distribution as _,
5
5
Rng ,
6
6
} ;
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ use crate::{
3
3
WeightedServiceKeys ,
4
4
} ;
5
5
use ahash:: AHashSet ;
6
- use rand:: distributions:: WeightedError ;
7
6
use std:: { fmt:: Debug , hash:: Hash , sync:: Arc } ;
8
7
9
8
#[ derive( Debug , Clone , PartialEq , Eq ) ]
@@ -73,7 +72,7 @@ impl<K> Distribution<K> {
73
72
74
73
pub fn random_available < T : IntoIterator < Item = ( K , u32 ) > > (
75
74
iter : T ,
76
- ) -> Result < Self , WeightedError > {
75
+ ) -> Result < Self , rand :: distr :: weighted :: Error > {
77
76
let weighted_keys = WeightedServiceKeys :: new (
78
77
iter. into_iter ( )
79
78
. map ( |( key, weight) | WeightedKey { key, weight } ) ,
Original file line number Diff line number Diff line change 1
1
use crate :: { keys:: KeyId , WeightedServiceKeys } ;
2
2
use ahash:: HashMap ;
3
3
use linkerd_stack:: { NewService , Service } ;
4
- use rand:: { distributions :: WeightedError , rngs:: SmallRng , SeedableRng } ;
4
+ use rand:: { rngs:: SmallRng , SeedableRng } ;
5
5
use std:: {
6
6
hash:: Hash ,
7
7
sync:: Arc ,
@@ -21,7 +21,7 @@ pub(crate) struct RandomAvailableSelection<K, S> {
21
21
}
22
22
23
23
fn new_rng ( ) -> SmallRng {
24
- SmallRng :: from_rng ( rand:: thread_rng ( ) ) . expect ( "RNG must initialize" )
24
+ SmallRng :: from_rng ( & mut rand:: rng ( ) )
25
25
}
26
26
27
27
impl < K , S > RandomAvailableSelection < K , S > {
92
92
// to `poll_ready` can try this backend again.
93
93
match selector. disable_backend ( id) {
94
94
Ok ( ( ) ) => { }
95
- Err ( WeightedError :: AllWeightsZero ) => {
95
+ Err ( rand :: distr :: weighted :: Error :: InsufficientNonZero ) => {
96
96
// There are no backends remaining.
97
97
break ;
98
98
}
You can’t perform that action at this time.
0 commit comments