Skip to content

Commit

Permalink
Update giganto_config to respond full configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
BLYKIM committed Aug 13, 2024
1 parent 622469e commit 710cfab
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,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

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ processing and real-time analytics.
You can run giganto by invoking the following command:

```sh
giganto --cert <CERT_PATH> --key <KEY_PATH> --ca <CA_PATH> <CENTRAL_SERVER>
giganto --cert <CERT_PATH> --key <KEY_PATH> --root <ROOT_PATH>
```

If you want to run giganto with local configuration file,

```sh
giganto -c <CONFIG_PATH> --cert <CERT_PATH> --key <KEY_PATH> --ca <CA_PATH> <CENTRAL_SERVER>
giganto -c <CONFIG_PATH> --cert <CERT_PATH> --key <KEY_PATH> --root <ROOT_PATH>
```

In the config file, you can specify the following options:
Expand Down Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions src/graphql/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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<PeerList>,

ack_transmission_cnt: u16,
}

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 9 additions & 6 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,

/// 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,
Expand All @@ -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,
Expand Down Expand Up @@ -143,7 +146,7 @@ fn default_config_builder() -> ConfigBuilder<DefaultState> {
.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")
Expand Down

0 comments on commit 710cfab

Please sign in to comment.