Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Simple merging logic for `Config` - Load config from system-wide locations (fixes #30) - Dynamically pick up changes from newly created config files (fixes #29) - Use `directories-rs` to find user level config directory path A new `ConfigWatcher` is introduced, which opportunistically watches the closest existing parent of target paths and rewatches dynamically accordingly. This way we can get notifications for new file creations in addition to modifications. `ConfigWatcher` also does debounce (100ms by default) to only trigger one config reload for multiple events in a short time period. The core idea of the watcher is as follow: Given a watching target path `/base/sub/config.toml`, a) readd watches if any segment in the path is created/removed; b) reload config only if the event is about the full target path. The actual implementation extends this idea to handle multiple targets. Please refer to `config_watcher.rs` for details and extensive test cases. A few design points: - Notify event handling is done in a separate thread, rather than in notify's internal event handler thread, because the code is more readable and calling unwatch/watch in that thread may lead to deadlock in some cases. (notify-rs/notify#410, notify-rs/notify#463) - For simplicity, `ConfigWatcher` doesn't provide infomation about which exact config file was changed, assuming a reload would need to read all config files anyway.
- Loading branch information