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

chore: SelectorType use snake_case #2962

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
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
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
Loading