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

Feature(strategy): Pisa-Proxy mysql read_write_splitting config #90

Closed
wbtlb opened this issue Jun 14, 2022 · 2 comments
Closed

Feature(strategy): Pisa-Proxy mysql read_write_splitting config #90

wbtlb opened this issue Jun 14, 2022 · 2 comments
Assignees
Labels
app:pisa-proxy Pisa-Proxy related changes
Milestone

Comments

@wbtlb
Copy link
Contributor

wbtlb commented Jun 14, 2022

Development Task

In Pisa-Proxy, maybe the config of read_write_spliting is like this:

[proxy.config.read_write_spliting]

[proxy.config.read_write_spliting.static]
default_target = "read"

[[proxy.config.read_write_spliting.static.rule]]
name = "read-rule"
type = ["regex"]
regex = ".*"
target = "read"
algorith_name = "random"

[[proxy.config.read_write_spliting.static.rule]]
name = "write-rule"
type = "regex"
regex = [".*"]
target = "read_write"
algorith_name = "roundrobin"

The structure of config is as follows

pub struct ReadWriteSplitting {
    #[serde(rename = "static")]
    pub undynamic: Option<ReadWriteSplittingStatic>,
}

#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct ReadWriteSplittingStatic {
    pub default_target: TargetRole,
    #[serde(rename = "rule")]
    pub rules: Vec<ReadWriteSplittingRule>,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(untagged)]
pub enum ReadWriteSplittingRule {
    Regex(RegexRule),
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct RegexRule {
    pub name: String,
    #[serde(rename = "type")]
    pub rule_type: String,
    pub regex: Vec<String>,
    pub target: TargetRole,
    pub algorithm_name: AlgorithmName,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum TargetRole {
    Read,
    ReadWrite,
}

After toml parse, we can get the data is as follows:

read_write_splitting: Some(
                ReadWriteSplitting {
                    undynamic: Some(
                        ReadWriteSplittingStatic {
                            default_target: Read,
                            rules: [
                                Regex(
                                    RegexRule {
                                        name: "read-rule",
                                        rule_type: "regex",
                                        regex: [
                                            ".*",
                                        ],
                                        target: Read,
                                        algorithm_name: Random,
                                    },
                                ),
                                Regex(
                                    RegexRule {
                                        name: "write-rule",
                                        rule_type: "regex",
                                        regex: [
                                            ".*",
                                        ],
                                        target: ReadWrite,
                                        algorithm_name: RoundRobin,
                                    },
                                ),
                            ],
                        },
                    ),
                },
            ),
@wbtlb wbtlb added the app:pisa-proxy Pisa-Proxy related changes label Jun 14, 2022
@wbtlb wbtlb added this to the v0.1.1 milestone Jun 14, 2022
@wbtlb wbtlb pinned this issue Jun 14, 2022
@wbtlb wbtlb unpinned this issue Jun 14, 2022
@xuanyuan300
Copy link
Contributor

#88

@wbtlb wbtlb changed the title Feature(strategy): WIP: Pisa-Proxy mysql read_write_splitting config Feature(strategy): Pisa-Proxy mysql read_write_splitting config Jun 23, 2022
@mlycore
Copy link
Member

mlycore commented Jun 24, 2022

Refers to #121

@mlycore mlycore closed this as completed Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app:pisa-proxy Pisa-Proxy related changes
Projects
None yet
Development

No branches or pull requests

3 participants