-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bind attribute support #11
Comments
Nice feature request! I'm thinking about adding similar features too. However, this feature seems not trivial.
So there is small space for us to bind something. I have two ideas so far. Wrappers for different sourceIn databend, to make our pub fn load() -> MetaResult<Self> {
let arg_conf = Self::parse();
let mut builder: serfig::Builder<Self> = serfig::Builder::default();
// Load from the config file first.
{
let config_file = if !arg_conf.config_file.is_empty() {
arg_conf.config_file.clone()
} else if let Ok(path) = env::var("METASRV_CONFIG_FILE") {
path
} else {
"".to_string()
};
builder = builder.collect(from_file(Toml, &config_file));
}
// Then, load from env.
let cfg_via_env: ConfigViaEnv = serfig::Builder::default()
.collect(from_env())
.build()
.map_err(|e| MetaError::InvalidConfig(e.to_string()))?;
builder = builder.collect(from_self(cfg_via_env.into()));
// Finally, load from args.
builder = builder.collect(from_self(arg_conf));
builder
.build()
.map_err(|e| MetaError::InvalidConfig(e.to_string()))
} This way needs a lot of Add bind support in
|
It's hard to impl than I thought, I've no idea yet. |
Example:
When I was using
sqlx
, to work withsqlx-cli
, command line to manage database migrations, I have to provide database connection options to it, which means I have to put database URL in command line args or environment variable, mostly I'd like to put this in file in name.env
.But in my application, the path to the field may not be
database.url
, I hope to bind the field in specific path.The text was updated successfully, but these errors were encountered: