From 2aa020947c2ae8aab9a5233da2c77b543c5c9d05 Mon Sep 17 00:00:00 2001 From: Wang XiangYu Date: Fri, 24 Jul 2020 16:45:11 +0800 Subject: [PATCH] optimize config code (#2996) * update Signed-off-by: wxyu * update pull request template Signed-off-by: wxyu --- .github/PULL_REQUEST_TEMPLATE.md | 8 ++- core/src/config/ServerConfig.h | 89 +++++++++++++++++--------------- 2 files changed, 53 insertions(+), 44 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 2f29cafc34..a866f3310b 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,10 @@ **What type of PR is this?** -API-change / BUG / Improvement / Documentation / Feature +[] API-change +[] BUG +[] Improvement +[] Documentation +[] Feature **Which branch you want to cherry-pick to?** @@ -20,4 +24,4 @@ Not Available **Additional documentation (e.g. design docs, usage docs, etc.):** -Not Available \ No newline at end of file +Not Available diff --git a/core/src/config/ServerConfig.h b/core/src/config/ServerConfig.h index 9e53841f1e..7cb87ac3d2 100644 --- a/core/src/config/ServerConfig.h +++ b/core/src/config/ServerConfig.h @@ -64,89 +64,94 @@ const configEnum SimdMap{ }; struct ServerConfig { - ConfigValue version{"unknown"}; + using String = ConfigValue; + using Bool = ConfigValue; + using Integer = ConfigValue; + using Floating = ConfigValue; + + String version{"unknown"}; struct Cluster { - ConfigValue enable{false}; - ConfigValue role{0}; + Bool enable{false}; + Integer role{0}; } cluster; struct General { - ConfigValue timezone{"unknown"}; - ConfigValue meta_uri{"unknown"}; + String timezone{"unknown"}; + String meta_uri{"unknown"}; } general; struct Network { struct Bind { - ConfigValue address{"unknown"}; - ConfigValue port{0}; + String address{"unknown"}; + Integer port{0}; } bind; struct Http { - ConfigValue enable{false}; - ConfigValue port{0}; + Bool enable{false}; + Integer port{0}; } http; } network; struct DB { - ConfigValue archive_disk_threshold{0.0}; - ConfigValue archive_days_threshold{0}; + Floating archive_disk_threshold{0.0}; + Integer archive_days_threshold{0}; } db; struct Storage { - ConfigValue path{"unknown"}; - ConfigValue auto_flush_interval{0}; - ConfigValue file_cleanup_timeout{0}; + String path{"unknown"}; + Integer auto_flush_interval{0}; + Integer file_cleanup_timeout{0}; } storage; struct Cache { - ConfigValue cache_size{0}; - ConfigValue cpu_cache_threshold{0.0}; - ConfigValue insert_buffer_size{0}; - ConfigValue cache_insert_data{false}; - ConfigValue preload_collection{"unknown"}; + Integer cache_size{0}; + Floating cpu_cache_threshold{0.0}; + Integer insert_buffer_size{0}; + Bool cache_insert_data{false}; + String preload_collection{"unknown"}; } cache; struct Metric { - ConfigValue enable{false}; - ConfigValue address{"unknown"}; - ConfigValue port{0}; + Bool enable{false}; + String address{"unknown"}; + Integer port{0}; } metric; struct Engine { - ConfigValue search_combine_nq{0}; - ConfigValue use_blas_threshold{0}; - ConfigValue omp_thread_num{0}; - ConfigValue simd_type{0}; + Integer search_combine_nq{0}; + Integer use_blas_threshold{0}; + Integer omp_thread_num{0}; + Integer simd_type{0}; } engine; struct GPU { - ConfigValue enable{false}; - ConfigValue cache_size{0}; - ConfigValue cache_threshold{0.0}; - ConfigValue gpu_search_threshold{0}; - ConfigValue search_devices{"unknown"}; - ConfigValue build_index_devices{"unknown"}; + Bool enable{false}; + Integer cache_size{0}; + Floating cache_threshold{0.0}; + Integer gpu_search_threshold{0}; + String search_devices{"unknown"}; + String build_index_devices{"unknown"}; } gpu; struct Tracing { - ConfigValue json_config_path{"unknown"}; + String json_config_path{"unknown"}; } tracing; struct WAL { - ConfigValue enable{false}; - ConfigValue recovery_error_ignore{false}; - ConfigValue buffer_size{0}; - ConfigValue path{"unknown"}; + Bool enable{false}; + Bool recovery_error_ignore{false}; + Integer buffer_size{0}; + String path{"unknown"}; } wal; struct Logs { - ConfigValue level{"unknown"}; + String level{"unknown"}; struct Trace { - ConfigValue enable{false}; + Bool enable{false}; } trace; - ConfigValue path{"unknown"}; - ConfigValue max_log_file_size{0}; - ConfigValue log_rotate_num{0}; + String path{"unknown"}; + Integer max_log_file_size{0}; + Integer log_rotate_num{0}; } logs; };