fuelen
Confispex - a schema for runtime variables
Hi all!
Confispex is a tool which allows defining specs for runtime configuration, cast values according to specified types and inspect them.
We needed a tool for managing complexity of runtime configuration. We have a lot of environment variables in monolithic application. > 150+ to be more precise. In such a situation runtime.exs quickly becomes polluted with badly designed anonymous functions which convert data to needed Elixir terms. Also, these functions have bad error reporting, because in a case of exception stacktrace isn’t available in runtime.exs file. Environment variable names are flat, it is essential to want to categorize them. We can’t switch to yaml-like configuration file, because existing infrastructure forces using environment variables. Variables can be used only in certain env, can have aliases, can be required/optional and this is needed to be documented somehow. The easiest way to specify that variable is required is by calling System.fetch_env!/1, but to see all required variables if they aren’t documented, you have to run application n times when n is a number of required variables. The team uses direnv in development and have to keep a template of .envrc file up-to-date for newcomers.
So, how confispex helps with issues mentioned above?
Elixir 1.11 allows running application code in runtime.exs, so confispex uses a schema defined in your application code to cast values to Elixir terms. Errors should not be reported immediately, but only when you ask a report. If confispex can’t cast value from store or default value to specified type, then nil is returned. Think about it as an advanced wrapper around System.get_env/1. Also, there is a mix task to generate a .envrc template from schema.
Check Getting Started page to see how it works.
Links:
Most Liked
fuelen
A new version v1.2.0 has been released!
There have been many changes since the initial post ![]()
Popular in Announcing
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









