Minor refactor for configs (#172)

* Changes shard struct to use vector of ServerConfig

* Adds to query router

* Change client disconnect with error message to warn instead of debug

* Add warning logs for clean up actions
This commit is contained in:
zainkabani
2022-09-22 13:07:02 -04:00
committed by GitHub
parent 85cc2f4147
commit 3a729bb75b
5 changed files with 32 additions and 39 deletions

View File

@@ -143,21 +143,12 @@ impl ConnectionPool {
let mut replica_number = 0;
for server in shard.servers.iter() {
let role = match server.2.as_ref() {
"primary" => Role::Primary,
"replica" => Role::Replica,
_ => {
error!("Config error: server role can be 'primary' or 'replica', have: '{}'. Defaulting to 'replica'.", server.2);
Role::Replica
}
};
let address = Address {
id: address_id,
database: shard.database.clone(),
host: server.0.clone(),
port: server.1 as u16,
role: role,
host: server.host.clone(),
port: server.port,
role: server.role,
address_index,
replica_number,
shard: shard_idx.parse::<usize>().unwrap(),
@@ -168,7 +159,7 @@ impl ConnectionPool {
address_id += 1;
address_index += 1;
if role == Role::Replica {
if server.role == Role::Replica {
replica_number += 1;
}