Automatic reload for configuration files. #15

Closed
lviggiano opened this Issue Feb 9, 2013 · 3 comments

Comments

Projects
None yet
1 participant
@lviggiano
Owner

lviggiano commented Feb 9, 2013

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

@lviggiano

This comment has been minimized.

Show comment
Hide comment
@lviggiano

lviggiano May 31, 2013

Owner

Started working on branch "automatic-reload" 9056c8b

The idea is to have an annotation like @HotReload(checkInterval) on class level, example:

@HotReload(5L, TimeUnit.MINUTES)
interface MyConfig extends Config {...}

Something like this would happen:

PropertyInvokationHandler.invoke() -> PropertyLoader.ensureUpToDate() -> LoadPolicy.checkAndUpdate()

With proper thread synchronization.

Owner

lviggiano commented May 31, 2013

Started working on branch "automatic-reload" 9056c8b

The idea is to have an annotation like @HotReload(checkInterval) on class level, example:

@HotReload(5L, TimeUnit.MINUTES)
interface MyConfig extends Config {...}

Something like this would happen:

PropertyInvokationHandler.invoke() -> PropertyLoader.ensureUpToDate() -> LoadPolicy.checkAndUpdate()

With proper thread synchronization.

@lviggiano

This comment has been minimized.

Show comment
Hide comment
@lviggiano

lviggiano Jun 14, 2013

Owner

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:

  • more tests
  • validation #30
  • documentation
  • asynchronous reload
  • notifications (ReloadEvent, ReloadListener)
Owner

lviggiano commented Jun 14, 2013

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:

  • more tests
  • validation #30
  • documentation
  • asynchronous reload
  • notifications (ReloadEvent, ReloadListener)
@lviggiano

This comment has been minimized.

Show comment
Hide comment
@lviggiano

lviggiano Jul 5, 2013

Owner

Documentation written to http://owner.aeonbits.org/docs/reload/

The validation will be postponed after 1.0.4 release probably. Hot reload can also live without validation for the moment.

Owner

lviggiano commented Jul 5, 2013

Documentation written to http://owner.aeonbits.org/docs/reload/

The validation will be postponed after 1.0.4 release probably. Hot reload can also live without validation for the moment.

@lviggiano lviggiano closed this Jul 5, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment