@@ -3,8 +3,8 @@ use arc_swap::ArcSwap;
33use log:: { error, info} ;
44use once_cell:: sync:: Lazy ;
55use 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 ;
88use std:: path:: Path ;
99use std:: sync:: Arc ;
1010use tokio:: fs:: File ;
@@ -250,7 +250,7 @@ impl ToString for PoolMode {
250250 }
251251}
252252
253- #[ derive( Serialize , Deserialize , Debug , Clone , PartialEq , Eq ) ]
253+ #[ derive( Serialize , Deserialize , Debug , Clone , PartialEq , Eq , Hash ) ]
254254pub struct Pool {
255255 #[ serde( default = "Pool::default_pool_mode" ) ]
256256 pub pool_mode : PoolMode ,
@@ -267,29 +267,8 @@ pub struct Pool {
267267 pub connect_timeout : u64 ,
268268
269269 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 > ,
293272}
294273
295274impl Pool {
@@ -302,8 +281,8 @@ impl Default for Pool {
302281 fn default ( ) -> Pool {
303282 Pool {
304283 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 ( ) ,
307286 default_role : String :: from ( "any" ) ,
308287 query_parser_enabled : false ,
309288 primary_reads_enabled : false ,
0 commit comments