Skip to content

Allow for weighting of config sources #1

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

Open
nugend opened this issue Jan 25, 2017 · 5 comments
Open

Allow for weighting of config sources #1

nugend opened this issue Jan 25, 2017 · 5 comments

Comments

@nugend
Copy link

nugend commented Jan 25, 2017

Config::sources could be an ordered collection and the config sources themselves could have a weighting:

config::merge(config::Environment::with_prefix("rust")::with_weight(10));

The weight itself would be an arbitrary value, of course (and presumably the ordered collection would preserve insertion order within weighting).

@mehcode
Copy link
Collaborator

mehcode commented Jan 25, 2017

config::merge(config::File::with_name("Settings").weight(10));
config::merge(config::Environment::with_prefix("rust").weight(5));

That feels fine. Interesting suggestion. I'll peg it to be added.

@mehcode
Copy link
Collaborator

mehcode commented Jun 23, 2017

Thinking more on this .. I don't like .weight being on the source API

  1. Config.merge_at takes a second, weight, parameter
config.merge_at(File::with_name("Settings"), 10);
  1. Complicate the return type story a bit more to make a fluid API here
config.merge(File::with_name("Settings")).with_weight(20);

Thoughts? Any other ideas?

@nugend
Copy link
Author

nugend commented Jun 23, 2017

I think that's fine. I'm trying to think of a situation where you'd really want to have multiple separate configs where the weight is actually associated with the sources you're merging from and drawing a blank. It's really down to the config using the source.

merge_at would be a new fn on impl Config, right?

@matthiasbeyer
Copy link
Member

Are you still interested in this, @nugend ?

@nugend
Copy link
Author

nugend commented Mar 18, 2021

I still think it's a worthwhile idea, but I don't have a practical application at the moment.

epage added a commit to epage/config-rs that referenced this issue Oct 22, 2024
chore(deps): update msrv to v1.65.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants