Skip to content
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

Pick up configuration file changes #19

Open
dtolnay opened this issue Feb 15, 2017 · 3 comments
Open

Pick up configuration file changes #19

dtolnay opened this issue Feb 15, 2017 · 3 comments

Comments

@dtolnay
Copy link

dtolnay commented Feb 15, 2017

  1. c.merge(/* config.yml */)
  2. c.get("k")
  3. modify config.yml -> k
  4. c.get("k")

The second get should reflect the changes to the config file.

I think we get this for free with the DeserializeSeed approach proposed in #13.

@tmccombs
Copy link
Contributor

This would either require watching the file for changes, or re-reading all config on every get, both of which have performance implications that would not acceptable in every application. I think this would be a great feature, as long as there is still a way to read config just once.

@mehcode
Copy link
Owner

mehcode commented Feb 15, 2017

Yeah.. I definitely want this as there are lot of use cases that could benefit. Here is the API in my head:

c.merge(File::with_name("Settings"));
c.get("key"); //= 1

c.watch(|| {
  // Do something when your config changes
});

Without calling c.watch, the configuration would not watch FS or listen for write events in Etcd.

This issue made me remember about #20. We should probably get that story down first before tackling automatic refresh.

@mehcode
Copy link
Owner

mehcode commented Jun 23, 2017

This is now possible ( check out https://github.com/mehcode/config-rs/blob/master/examples/watch/src/main.rs )

A couple more questions to answer before .watch should be added.

  1. Is Config.watch stating that we are watching all sources? I'd think so.

  2. Should there be a way to opt-out or opt-in to watching at a per-source level?

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