Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Automatic reload for configuration files. #15
It is not uncommon for some application to have a consistent and efficient "hot reload" for configuration files. At the moment, the configuration is loaded when the create method is invoked, and no cache is implemented; so it would not be hard for a user to implement some reload mechanism from outside the API. But, things would be better if the reload is triggered by file change, transparently. This should of course be kept thread safe to avoid inconsistent states.
link to #5
Started working on branch "automatic-reload" 9056c8b
The idea is to have an annotation like @hotreload(checkInterval) on class level, example:
Something like this would happen:
PropertyInvokationHandler.invoke() -> PropertyLoader.ensureUpToDate() -> LoadPolicy.checkAndUpdate()
With proper thread synchronization.
Basic reload is implemented.
The problem is that if the configuration is invalid (example, a non-numeric value for a method returning a numeric value) will generate an exception when the method is invoked, a runtime exception.
So, it would be best to have the validation feature, so that when reload is triggered the validation ensures that the new configuration is valid before to adopt it; and if it's not valid then the new configuration is discarded with some log message somewhere.
At the moment the reload happens synchronously (when a method on the proxy is invoked), but it would be nice if the user could chose also an asynchronous reload (by a thread in background) with a notification mechanism based on listeners.
Things to be done before completing this issue: