More admin (#53)

* more admin

* more admin

* show lists

* tests
This commit is contained in:
Lev Kokotov
2022-03-01 22:49:43 -08:00
committed by GitHub
parent aaeef69d59
commit d4186b7815
4 changed files with 157 additions and 16 deletions

View File

@@ -52,6 +52,7 @@ pub struct Address {
pub port: String,
pub shard: usize,
pub role: Role,
pub replica_number: usize,
}
impl Default for Address {
@@ -60,11 +61,22 @@ impl Default for Address {
host: String::from("127.0.0.1"),
port: String::from("5432"),
shard: 0,
replica_number: 0,
role: Role::Replica,
}
}
}
impl Address {
pub fn name(&self) -> String {
match self.role {
Role::Primary => format!("shard_{}_primary", self.shard),
Role::Replica => format!("shard_{}_replica_{}", self.shard, self.replica_number),
}
}
}
#[derive(Clone, PartialEq, Hash, std::cmp::Eq, Deserialize, Debug)]
pub struct User {
pub name: String,