fuelen

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:

https://github.com/prosapient/confispex

Most Liked

fuelen

fuelen

A new version v1.2.0 has been released!

There have been many changes since the initial post :slightly_smiling_face:

Where Next?

Popular in Announcing Top

mspanc
I am pleased to announce an initial release of the Membrane Framework - an Elixir-based framework with special focus on processing multim...
New
tmbb
I’ve decided to create this topic to discuss optimization possibilities for something like Phoenix LiveView. I’ve created this topic unde...
144 10789 141
New
kip
ex_cldr provides localisation and internationalisation support based upon the data from the Unicode CLDR project. Unicode released CLDR ...
407 13256 120
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New
wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
zachdaniel
Ash Framework What is Ash? Ash Framework is a declarative, resource-oriented application development framework for Elixir. A resource can...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement