diff --git a/src/config.rs b/src/config.rs index ae006b3..ed33810 100644 --- a/src/config.rs +++ b/src/config.rs @@ -64,6 +64,8 @@ pub struct Address { pub database: String, pub role: Role, pub replica_number: usize, + pub username: String, + pub poolname: String, } impl Default for Address { @@ -76,6 +78,8 @@ impl Default for Address { replica_number: 0, database: String::from("database"), role: Role::Replica, + username: String::from("username"), + poolname: String::from("poolname"), } } } @@ -84,11 +88,11 @@ impl Address { /// Address name (aka database) used in `SHOW STATS`, `SHOW DATABASES`, and `SHOW POOLS`. pub fn name(&self) -> String { match self.role { - Role::Primary => format!("{}_shard_{}_primary", self.database, self.shard), + Role::Primary => format!("{}_shard_{}_primary", self.poolname, self.shard), Role::Replica => format!( "{}_shard_{}_replica_{}", - self.database, self.shard, self.replica_number + self.poolname, self.shard, self.replica_number ), } } diff --git a/src/pool.rs b/src/pool.rs index 76445c8..4a70078 100644 --- a/src/pool.rs +++ b/src/pool.rs @@ -114,12 +114,14 @@ impl ConnectionPool { let address = Address { id: address_id, - database: pool_name.clone(), + database: shard.database.clone(), host: server.0.clone(), port: server.1.to_string(), role: role, replica_number, shard: shard_idx.parse::().unwrap(), + username: user_info.username.clone(), + poolname: pool_name.clone(), }; address_id += 1;