Updatable Scala config

Scala-updatable-config library is an enhanced version of pure config with ability to dynamically update configuration from multiple backends. Best part of our tool is that there is no need to redeploy application if you want to change some basic configuration.

Great help with writing this library was an awesome book about shapeless library “The Type Astronaut’s Guide to Shapeless”.

Project is open source and you can find it here:

But why?

Some of you may ask why we tried to reinvent the wheel, and write some ‘yet another configuration library’. Reason is quite simple, we didn’t want go through redeploy process just because there was a need to change something in configuration. Additionally, from security reason, we didn’t want to use environment variables.

We achieve that by using distributed key-value stores, Consul and Vault 
Consul is service discovery component where we register services and keep simple configuration for them. Vault is tool for storing all kind of secrets, from simple key-value to managing credentials to database.

How to use it?

Best way of describing how something works is by showing it.

Let’s start with defining ‘application.conf’ file:

What is worth noticing is the following line


It’s helpful for testing purposes, with that set on true library will look just into file to get values.

ADT for above config file:

Now we are ready to define object with configuration.

Most of library magic is hidden behind method checkForUpdates where we defined:

  • Path to ‘key‘’.
  • ValueGetter which try to return value under path.
  • Callback function which is called when value in path changed.
  • Current value used when there is no change or we can’t find path.

And that’s all, with that configuration every time you reload you application or run `checkForUpdates`on ApplicationConfig you will get new values from backend.

There is room for improvement!

At this point we support only two backends, but with our approach we can easily add more like Apache Zookeeper or Etcd. In addition, we can certainly improve support for coproducts. 
What is important to us is better utilization of Vault backend. Currently we support only token for predefined AppRole but there is much more we can use.

Final words.

With our approach to dynamic application configuration you can simplify way of configuring application. It became standard in our Scala applications and I encourage you to try it out :)

We are looking forward to any feedback, pull requests, issue requests.

Source code: