koanf
koanf copied to clipboard
adding Unwatch function for file provider
@rhnvrm , I have made the following changes:
- Changed function name
UnWatch->Unwatch - Added comment for the
Unwatchfunction - Using
Closefunction for all the watchers - Adding an array to the file structure as there can be multiple
f.Watch()calls, hence an array would store all the watchers
@prateek-narsinghani thanks for the PR. Could you please add tests for this as well?
@knadh I have added a test for the Unwatch function. Let me know if any further changes are required.
I finally got around to looking into this. Please take a look at: https://github.com/knadh/koanf/pull/306
It addresses a couple of issues in this PR:
- Unwatch() triggers random channel closure errors (main channel or error channel) to the callback, which the caller is expected to handle. Unwatch() shouldn't trigger these errors.
- The
f.w == nilissue where once Unwatched(), the watcher couldn't be used again. Also, settingf.wto nil would require locking.