fuelen

fuelen

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

First Post! Switch mode

fuelen

fuelen OP

A new version v1.2.0 has been released!

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

— All posts loaded —

Where Next? Top

Trending in Announcing Top

bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
387 15136 120
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
New
woylie
Phoenix components for pagination, sortable tables and filter forms with Flop and (optionally) Ecto. pagination cursor pagination sorta...
New
kip
Please say hi to a new lib, Astro that aims to deliver easy-to-consume astronomy calculations of practical use. For now it only calculat...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

Other Trending Topics Top

juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New

We're in Beta

About us Mission Statement