An open API service indexing awesome lists of open source software.

https://github.com/centralnicgroup-opensource/dynamic_config

a simple elixir application config updater
https://github.com/centralnicgroup-opensource/dynamic_config

Last synced: 4 months ago
JSON representation

a simple elixir application config updater

Awesome Lists containing this project

README

        

# DynamicConfig

Having the option to manage config in a database and update application
behaviour by changing DB documents is handy especially if things break
and running commands on all affected machines is slow.

This app handles application configuration and updates it every n
seconds to make sure that we can tweak application behaviour on the fly.
It currently only supports CouchDB but could easily be extended to
support other backends by implementing a new `DynamicConfig.BACKEND`
module.

## Installation

This is currently not published to Hex so pull it from git by adding
this to your dependencies:

```elixir
def deps do
[{:dynamic_config, github: "iwantmyname/dynamic_config"}]
end
```

## Usage

By adding the dependency and adding `:dynamic_config` to your
applications the app will start a GenServer at application startup. This
GenServer will trigger a read to the backend for updated config settings
and update the application config if something changed. It currently
determines changes by looking at the document revision of the config
document. To configure behaviour of the application please add the
following configuration parameter to your application:

```elixir
config :dynamic_config,
interval: 120_000, # update interval, defaults to 60_000
# milliseconds (1 min)
config_db: "conf" # defaults to "config"
targets: [
%{target: :nsearch, source: "search", backend: DynamicConfig.CouchDB},
%{target: :something, source: "something/else", backend: DynamicConfig.Vault}
]
```

The `update` part is the most important one as it defines the
application environment we want to modify, this would normally be your
main application. Say your main app is `:my_app` then the dynamic
updater would add every key in the document with the `_id: "my_app"` to
your `:my_app` application environment.