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
- Host: GitHub
- URL: https://github.com/centralnicgroup-opensource/dynamic_config
- Owner: centralnicgroup-opensource
- License: mit
- Created: 2017-02-27T00:34:11.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-02T07:02:47.000Z (over 8 years ago)
- Last Synced: 2025-01-15T19:24:46.936Z (5 months ago)
- Language: Elixir
- Size: 22.5 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.