From fcb6bd33b0d99399b497b772a5da0bcbd2a1717f Mon Sep 17 00:00:00 2001 From: Bly Kim Date: Fri, 9 Aug 2024 11:54:27 +0900 Subject: [PATCH] Update `giganto_config` to respond full configuration --- CHANGELOG.md | 1 + Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 6 +++--- src/graphql/status.rs | 23 +++++++++++++++++++++++ src/settings.rs | 15 +++++++++------ 6 files changed, 38 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f6c48a0..31d9fa58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ Versioning](https://semver.org/spec/v2.0.0.html). - Changed to support command line interface. - Removed `cert`, `key`, `root` fields from config file. - Changed `set_giganto_config` to receive toml-string with full configuration. +- Updated `giganto_config` to respond full configuration. ## [0.20.0] - 2024-05-17 diff --git a/Cargo.lock b/Cargo.lock index ac95f8cc..e1f0ae2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1067,7 +1067,7 @@ dependencies = [ [[package]] name = "giganto" -version = "0.21.0-alpha.2" +version = "0.21.0-alpha.3" dependencies = [ "anyhow", "async-graphql", diff --git a/Cargo.toml b/Cargo.toml index c89e617d..3e91f2f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "giganto" -version = "0.21.0-alpha.2" +version = "0.21.0-alpha.3" edition = "2021" [lib] diff --git a/README.md b/README.md index 2b7e0551..4207262c 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,13 @@ processing and real-time analytics. You can run giganto by invoking the following command: ```sh -giganto --cert --key --ca +giganto --cert --key --root ``` If you want to run giganto with local configuration file, ```sh -giganto -c --cert --key --ca +giganto -c --cert --key --root ``` In the config file, you can specify the following options: @@ -77,7 +77,7 @@ certificate/key from the tests folder.) ```sh cargo run -- -c tests/node1/config.toml --cert tests/node1/cert.pem \ ---key tests/node1/key.pem --root tests/root.pem hostname@address +--key tests/node1/key.pem --root tests/root.pem ``` ## License diff --git a/src/graphql/status.rs b/src/graphql/status.rs index 8426a2c6..715bcbcd 100644 --- a/src/graphql/status.rs +++ b/src/graphql/status.rs @@ -18,8 +18,13 @@ const CONFIG_INGEST_SRV_ADDR: &str = "ingest_srv_addr"; pub const CONFIG_PUBLISH_SRV_ADDR: &str = "publish_srv_addr"; pub const CONFIG_GRAPHQL_SRV_ADDR: &str = "graphql_srv_addr"; const CONFIG_RETENTION: &str = "retention"; +const CONFIG_DATA_DIR: &str = "data_dir"; +const CONFIG_LOG_DIR: &str = "log_dir"; +const CONFIG_EXPORT_DIR: &str = "export_dir"; const CONFIG_MAX_OPEN_FILES: &str = "max_open_files"; const CONFIG_MAX_MB_OF_LEVEL_BASE: &str = "max_mb_of_level_base"; +const CONFIG_NUM_OF_THREAD: &str = "num_of_thread"; +const CONFIG_MAX_SUB_COMPACTIONS: &str = "max_sub_compactions"; const CONFIG_ADDR_TO_PEERS: &str = "addr_to_peers"; const CONFIG_PEER_LIST: &str = "peers"; const CONFIG_ACK_TRANSMISSION: &str = "ack_transmission"; @@ -74,10 +79,18 @@ struct GigantoConfig { publish_srv_addr: String, graphql_srv_addr: String, retention: String, + data_dir: String, + log_dir: String, + export_dir: String, + max_open_files: i32, max_mb_of_level_base: u64, + num_of_thread: i32, + max_sub_compactions: u32, + addr_to_peers: String, peer_list: Vec, + ack_transmission_cnt: u16, } @@ -130,9 +143,14 @@ impl GigantoStatusQuery { let publish_srv_addr = parse_toml_element_to_string(CONFIG_PUBLISH_SRV_ADDR, &doc)?; let graphql_srv_addr = parse_toml_element_to_string(CONFIG_GRAPHQL_SRV_ADDR, &doc)?; let retention = parse_toml_element_to_string(CONFIG_RETENTION, &doc)?; + let data_dir = parse_toml_element_to_string(CONFIG_DATA_DIR, &doc)?; + let log_dir = parse_toml_element_to_string(CONFIG_LOG_DIR, &doc)?; + let export_dir = parse_toml_element_to_string(CONFIG_EXPORT_DIR, &doc)?; let max_open_files = parse_toml_element_to_integer(CONFIG_MAX_OPEN_FILES, &doc)?; let max_mb_of_level_base = parse_toml_element_to_integer(CONFIG_MAX_MB_OF_LEVEL_BASE, &doc)?; + let num_of_thread = parse_toml_element_to_integer(CONFIG_NUM_OF_THREAD, &doc)?; + let max_sub_compactions = parse_toml_element_to_integer(CONFIG_MAX_SUB_COMPACTIONS, &doc)?; let ack_transmission_cnt = parse_toml_element_to_integer(CONFIG_ACK_TRANSMISSION, &doc)?; let mut peer_list = Vec::new(); let addr_to_peers = if doc.get(CONFIG_ADDR_TO_PEERS).is_some() { @@ -168,8 +186,13 @@ impl GigantoStatusQuery { publish_srv_addr, graphql_srv_addr, retention, + data_dir, + log_dir, + export_dir, max_open_files, max_mb_of_level_base, + num_of_thread, + max_sub_compactions, addr_to_peers, peer_list, ack_transmission_cnt, diff --git a/src/settings.rs b/src/settings.rs index 00753940..30d6f641 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -16,24 +16,27 @@ const DEFAULT_RETENTION: &str = "100d"; const DEFAULT_MAX_OPEN_FILES: i32 = 8000; const DEFAULT_MAX_MB_OF_LEVEL_BASE: u64 = 512; const DEFAULT_NUM_OF_THREAD: i32 = 8; -const DEFAULT_MAX_SUBCOMPACTIONS: u32 = 2; +const DEFAULT_MAX_SUB_COMPACTIONS: u32 = 2; #[derive(Parser, Debug)] +#[command(version = env!("CARGO_PKG_VERSION"))] pub struct Args { /// Path to the local configuration TOML file #[arg(short, value_name = "CONFIG_PATH")] pub config: Option, + /// Path to the certificate file #[arg(long, value_name = "CERT_PATH")] pub cert: String, + /// Path to the key file #[arg(long, value_name = "KEY_PATH")] pub key: String, + /// Path to the root CA file #[arg(long, value_name = "ROOT_PATH")] pub root: String, - /// Central management server "hostname@address" - pub central_server: String, + /// Enable the repair mode #[arg(long)] pub repair: bool, @@ -51,8 +54,8 @@ pub struct Settings { pub retention: Duration, // Data retention period #[serde(deserialize_with = "deserialize_socket_addr")] pub graphql_srv_addr: SocketAddr, // IP address & port to graphql - pub log_dir: PathBuf, //giganto's syslog path - pub export_dir: PathBuf, //giganto's export file path + pub log_dir: PathBuf, // giganto's syslog path + pub export_dir: PathBuf, // giganto's export file path // db options pub max_open_files: i32, @@ -143,7 +146,7 @@ fn default_config_builder() -> ConfigBuilder { .expect("default max mb of level base") .set_default("num_of_thread", DEFAULT_NUM_OF_THREAD) .expect("default number of thread") - .set_default("max_sub_compactions", DEFAULT_MAX_SUBCOMPACTIONS) + .set_default("max_sub_compactions", DEFAULT_MAX_SUB_COMPACTIONS) .expect("default max subcompactions") .set_default("cfg_path", config_path.to_str().expect("path to string")) .expect("default config dir")