greptimedb
greptimedb copied to clipboard
Set default values when loading config file
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());
...
}
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.
I think it's resolved in https://github.com/GreptimeTeam/greptimedb/pull/820
Already added #[serde(default)]
for all configurations.