cmd/
options.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use clap::Parser;
16use common_config::Configurable;
17use common_runtime::global::RuntimeOptions;
18use plugins::PluginOptions;
19use serde::{Deserialize, Serialize};
20
21#[derive(Parser, Default, Debug, Clone)]
22pub struct GlobalOptions {
23    #[clap(long, value_name = "LOG_DIR")]
24    #[arg(global = true)]
25    pub log_dir: Option<String>,
26
27    #[clap(long, value_name = "LOG_LEVEL")]
28    #[arg(global = true)]
29    pub log_level: Option<String>,
30
31    #[cfg(feature = "tokio-console")]
32    #[clap(long, value_name = "TOKIO_CONSOLE_ADDR")]
33    #[arg(global = true)]
34    pub tokio_console_addr: Option<String>,
35}
36
37// TODO(LFC): Move logging and tracing options into global options, like the runtime options.
38/// All the options of GreptimeDB.
39#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)]
40#[serde(default)]
41pub struct GreptimeOptions<T> {
42    /// The runtime options.
43    pub runtime: RuntimeOptions,
44    /// The plugin options.
45    pub plugins: Vec<PluginOptions>,
46
47    /// The options of each component (like Datanode or Standalone) of GreptimeDB.
48    #[serde(flatten)]
49    pub component: T,
50}
51
52impl<T: Configurable> Configurable for GreptimeOptions<T> {
53    fn env_list_keys() -> Option<&'static [&'static str]> {
54        T::env_list_keys()
55    }
56}