smallrye / smallrye-config

SmallRye Config - A Java Configuration library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update Config Mapping instance based on Config Source changes

alsasian opened this issue · comments

Based on Mappings documentation, Config Mapping instances are cached:

Config Mapping instances are cached. They are populated when the Config instance is initialized and their values are not updated on Config Source changes.

As we have more use cases that require certain configuration item to be configurable at runtime, is there a plan to make the Config Mapping instances updated based on Config Source change? Or is there another approach that I should consider instead here?

As we have more use cases that require certain configuration item to be configurable at runtime, is there a plan to make the Config Mapping instances updated based on Config Source change?

This is a complex problem to handle, so we have chosen the easiest solution, which is not to support it :)

There are a few questions that we need to be able to answer:

  • How do we know that the config changed?
  • What happens if the new configuration is invalid?
  • What about mappings that were injected into Singletons or ApplicationScoped beans?
  • What about the configuration that is used at the application start? For instance, database connection configuration.

While it is possible to answer these questions, we always felt that the user experience wouldn't be great.

There is a trick that you can use. Create a new SmallRyeConfig instance, which forces loading all the sources again and to get updated mappings. For instance, check