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

Add Watch alternative to provider.File to return Watcher obj #294

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gczuczy
Copy link

@gczuczy gczuczy commented May 10, 2024

This way the watcher object can be closed and deallocated properly.

The problem this solved, is when koanf is being used with managed dependency injection and the koanf instance is deallocated and reallocated at some time in the code. In these cases the created watchers are permanent, and koanf is still triggering the callbacks on obsolet koanf instances (which already belong to the GC).

We've found this during unit testing, where each test is bringing up its own config instance along with koanf, and watcher callbacks are being called after we have "deallocated" (removed the references to, as there's no Close() or anything similar on koanf.Koanf) to the koanf instance belonging to the test.

This way the watcher object can be closed and deallocated properly.
@gczuczy
Copy link
Author

gczuczy commented May 10, 2024

Just noticed lately, that this PR is addressing the same issue as #245.
Please, either ways, solve this standing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant