Improved runtime config support
bernardd opened this issue · 1 comments
Hi - I want to use this library in our app, however because we run it in multiple different environments from a single release, all our config comes in through environment variables (we also do this to supply passwords without putting them in hardwired config).
While it's possible to provide a Redis URL using the {:system, url}
magic, it's kind of clunky trying to munge the individual bits of config (SSL, password, server etc) into another environment variable before startup, and seems like pointless effort when internally Redix is just going to split them all up again. Plus it still doesn't allow any other bits (TTL etc) to be configured dynamically.
There's generally two ways to fix this that I've seen - my preferred one is to add generalised support using Confex. That requires no changes to the config spec, but allows each individual field to be specified as {:system, :type, "ENV_VAR", default}
.
However some people don't like having an added dependency in their library, so an alternative is to allow something in the config like {:callback, Module, :function}
and have the application provide a function which returns config.
I'm happy to implement whichever of those you prefer (or some alternative) - just let me know.
Hi, thank you for the interest in the library.
I'm aware of the limitation, but before addressing it I was waiting for Elixir to take a stance on runtime configuration, which has been planned for a while. It has now landed in the recently released 1.9.
More in general, I think at this point I'd like to try to add support for the init
callbacks that the Elixir core team has been recommending. That would be a customization entry point for all the configuration of the library, which seems handy.
In the meantime, to get you unlocked, I suppose that either Confex
or deferred_config
could solve the problem in your application.