Skip to content

Commit

Permalink
chore: SelectorType use snake_case (#2962)
Browse files Browse the repository at this point in the history
chore: let SelectorType use snake_case
  • Loading branch information
fengjiachun authored Dec 20, 2023
1 parent 839e653 commit 5f8c175
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions config/metasrv.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 12 additions & 6 deletions src/meta-srv/src/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ impl TryFrom<&str> for SelectorType {

fn try_from(value: &str) -> Result<Self> {
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,
}
Expand All @@ -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";
Expand Down

0 comments on commit 5f8c175

Please sign in to comment.