From 9b4426b837c52f26282d998906a3d3f172421e79 Mon Sep 17 00:00:00 2001 From: jeremyhi Date: Tue, 19 Dec 2023 21:04:26 +0800 Subject: [PATCH] chore: let SelectorType use snake_case --- config/metasrv.example.toml | 6 +++--- src/meta-srv/src/selector.rs | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/config/metasrv.example.toml b/config/metasrv.example.toml index 0be99c1dd048..af7e92f632ca 100644 --- a/config/metasrv.example.toml +++ b/config/metasrv.example.toml @@ -7,10 +7,10 @@ server_addr = "127.0.0.1:3002" # Etcd server address, "127.0.0.1:2379" by default. store_addr = "127.0.0.1:2379" # Datanode selector type. -# - "LeaseBased" (default value). -# - "LoadBased" +# - "lease_based" (default value). +# - "load_based" # For details, please see "https://docs.greptime.com/developer-guide/metasrv/selector". -selector = "LeaseBased" +selector = "lease_based" # Store data in memory, false by default. use_memory_store = false # Whether to enable greptimedb telemetry, true by default. diff --git a/src/meta-srv/src/selector.rs b/src/meta-srv/src/selector.rs index 140f4e5711d5..44ce0b2c8cb4 100644 --- a/src/meta-srv/src/selector.rs +++ b/src/meta-srv/src/selector.rs @@ -67,8 +67,8 @@ impl TryFrom<&str> for SelectorType { fn try_from(value: &str) -> Result { match value { - "LoadBased" => Ok(SelectorType::LoadBased), - "LeaseBased" => Ok(SelectorType::LeaseBased), + "load_based" | "LoadBased" => Ok(SelectorType::LoadBased), + "lease_based" | "LeaseBased" => Ok(SelectorType::LeaseBased), other => error::UnsupportedSelectorTypeSnafu { selector_type: other, } @@ -89,12 +89,18 @@ mod tests { #[test] fn test_convert_str_to_selector_type() { - let leasebased = "LeaseBased"; - let selector_type = leasebased.try_into().unwrap(); + let lease_based = "lease_based"; + let selector_type = lease_based.try_into().unwrap(); + assert_eq!(SelectorType::LeaseBased, selector_type); + let lease_based = "LeaseBased"; + let selector_type = lease_based.try_into().unwrap(); assert_eq!(SelectorType::LeaseBased, selector_type); - let loadbased = "LoadBased"; - let selector_type = loadbased.try_into().unwrap(); + let load_based = "load_based"; + let selector_type = load_based.try_into().unwrap(); + assert_eq!(SelectorType::LoadBased, selector_type); + let load_based = "LoadBased"; + let selector_type = load_based.try_into().unwrap(); assert_eq!(SelectorType::LoadBased, selector_type); let unknown = "unknown";