@@ -3,8 +3,8 @@ use arc_swap::ArcSwap;
3
3
use log:: { error, info} ;
4
4
use once_cell:: sync:: Lazy ;
5
5
use serde_derive:: { Deserialize , Serialize } ;
6
- use std:: collections:: { HashMap , HashSet } ;
7
- use std:: hash:: { Hash , Hasher } ;
6
+ use std:: collections:: { BTreeMap , HashMap , HashSet } ;
7
+ use std:: hash:: Hash ;
8
8
use std:: path:: Path ;
9
9
use std:: sync:: Arc ;
10
10
use tokio:: fs:: File ;
@@ -250,7 +250,7 @@ impl ToString for PoolMode {
250
250
}
251
251
}
252
252
253
- #[ derive( Serialize , Deserialize , Debug , Clone , PartialEq , Eq ) ]
253
+ #[ derive( Serialize , Deserialize , Debug , Clone , PartialEq , Eq , Hash ) ]
254
254
pub struct Pool {
255
255
#[ serde( default = "Pool::default_pool_mode" ) ]
256
256
pub pool_mode : PoolMode ,
@@ -267,29 +267,8 @@ pub struct Pool {
267
267
pub connect_timeout : u64 ,
268
268
269
269
pub sharding_function : String ,
270
- pub shards : HashMap < String , Shard > ,
271
- pub users : HashMap < String , User > ,
272
- }
273
-
274
- impl Hash for Pool {
275
- fn hash < H : Hasher > ( & self , state : & mut H ) {
276
- self . pool_mode . hash ( state) ;
277
- self . default_role . hash ( state) ;
278
- self . query_parser_enabled . hash ( state) ;
279
- self . primary_reads_enabled . hash ( state) ;
280
- self . sharding_function . hash ( state) ;
281
- self . connect_timeout . hash ( state) ;
282
-
283
- for ( key, value) in & self . shards {
284
- key. hash ( state) ;
285
- value. hash ( state) ;
286
- }
287
-
288
- for ( key, value) in & self . users {
289
- key. hash ( state) ;
290
- value. hash ( state) ;
291
- }
292
- }
270
+ pub shards : BTreeMap < String , Shard > ,
271
+ pub users : BTreeMap < String , User > ,
293
272
}
294
273
295
274
impl Pool {
@@ -302,8 +281,8 @@ impl Default for Pool {
302
281
fn default ( ) -> Pool {
303
282
Pool {
304
283
pool_mode : Pool :: default_pool_mode ( ) ,
305
- shards : HashMap :: from ( [ ( String :: from ( "1" ) , Shard :: default ( ) ) ] ) ,
306
- users : HashMap :: default ( ) ,
284
+ shards : BTreeMap :: from ( [ ( String :: from ( "1" ) , Shard :: default ( ) ) ] ) ,
285
+ users : BTreeMap :: default ( ) ,
307
286
default_role : String :: from ( "any" ) ,
308
287
query_parser_enabled : false ,
309
288
primary_reads_enabled : false ,
0 commit comments