greptimedb icon indicating copy to clipboard operation
greptimedb copied to clipboard

Set default values when loading config file

Open zyy17 opened this issue 2 years ago • 1 comments

If we use --config-file to start our service, we don't set the default values(if the value is not set by the config file, set it as the default value). I think maybe we need some kind of merge() operation, for example:

    fn try_from(cmd: StartCommand) -> Result<Self> {
        let mut opts: FrontendOptions = if let Some(path) = cmd.config_file {
            toml_loader::from_file!(&path)?
        } else {
            FrontendOptions::default()
        };

        // merge the same struct according to some kind of strategy.
        merge(opts, FrontendOptions::default());
        ...
    }

zyy17 avatar Nov 13 '22 14:11 zyy17

Furthermore, I think maybe we need some kind of configuration builder(like config-rs, serfig, ...) to unify the logic of processing configuration and then merge multiple configuration sources (file/cli/env) into one option according to some kind of priority rules.

zyy17 avatar Nov 13 '22 14:11 zyy17

I think it's resolved in https://github.com/GreptimeTeam/greptimedb/pull/820

Already added #[serde(default)] for all configurations.

killme2008 avatar Jan 13 '23 07:01 killme2008