Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sharding): fix parse sharding toml config failed #381

Merged
merged 1 commit into from
Nov 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pisa-proxy/proxy/strategy/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,18 @@ pub struct Sharding {
pub database_table_strategy: Option<StrategyType>,
}

// There is no explicit tag identifying which variant the data contains.
// Serde will try to match the data against each variant in order and the first one that deserializes successfully is the one returned.
// Refrence Link: https://serde.rs/enum-representations.html
// DatabaseTableStrategyConfig struct must be guaranteed to be matched firstly
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(untagged)]
pub enum StrategyType {
DatabaseTableStrategyConfig(DatabaseTableStrategyConfig),
DatabaseStrategyConfig(DatabaseStrategyConfig),
DatabaseStrategyInline(StrategyInline),
TableStrategyConfig(TableStrategyConfig),
DatabaseStrategyInline(StrategyInline),
TableStrategyInline(StrategyInline),
DatabaseTableStrategyConfig(DatabaseTableStrategyConfig),
}

#[derive(Debug, Serialize, Deserialize, Clone)]
Expand Down Expand Up @@ -194,10 +198,10 @@ pub struct TableStrategyConfig {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct DatabaseTableStrategyConfig {
pub database_sharding_algorithm_name: ShardingAlgorithmName,
pub table_sharding_algorithm_name: ShardingAlgorithmName,
pub database_sharding_column: String,
pub table_sharding_algorithm_name: ShardingAlgorithmName,
pub table_sharding_column: String,
pub shading_count: u32,
pub sharding_count: u32,
}

fn default_monitor_period() -> u64 {
Expand Down