Automatic sharding: part one of many (#194)

Starting automatic sharding
This commit is contained in:
Lev Kokotov
2022-10-25 11:47:41 -07:00
committed by GitHub
parent fa267733d9
commit 0524787d31
5 changed files with 169 additions and 17 deletions

View File

@@ -267,6 +267,10 @@ pub struct Pool {
pub connect_timeout: Option<u64>,
pub sharding_function: ShardingFunction,
#[serde(default = "Pool::default_automatic_sharding_key")]
pub automatic_sharding_key: Option<String>,
pub shards: BTreeMap<String, Shard>,
pub users: BTreeMap<String, User>,
}
@@ -276,6 +280,10 @@ impl Pool {
PoolMode::Transaction
}
pub fn default_automatic_sharding_key() -> Option<String> {
None
}
pub fn validate(&self) -> Result<(), Error> {
match self.default_role.as_ref() {
"any" => (),
@@ -318,6 +326,7 @@ impl Default for Pool {
query_parser_enabled: false,
primary_reads_enabled: false,
sharding_function: ShardingFunction::PgBigintHash,
automatic_sharding_key: None,
connect_timeout: None,
}
}