akoutmos

akoutmos

Author of Build a Weather Station with Elixir and Nerves

How are you handling run-time configuration for Plugs? (poll)

I was wondering how people are handling run-time configuration of their Plugs in their Phoenix applications as of today:

  • Using {:system, “ENV_VAR”} tuple (if lib supports it)
  • Using Mix Releases & Config module (if lib supports it)
  • Wrap Plug libraries with your own Plugs to control configuration
  • I don’t need run-time configuration of plugs
  • Other (please add comment as to what you use)
0 voters

I am also curious what problems people encounter with configuring Plugs at run-time and if people would like to see some community best practices/guidelines around Plugs that allow them to be more configurable in a deployed setting (maybe documentation like this exists and I just don’t know about it??).

Personally, I have been going the route of having my Plug libraries configurable via the Config module and my config/releases.ex file.

Thanks for the input, and stay safe during these tough coronavirus days!!

Most Liked

akoutmos

akoutmos

Author of Build a Weather Station with Elixir and Nerves

I think it gets to the fundamental problem of what can you do during build-time, and what has to wait during run-time. For example, you may have a CORS plug, but that requires inputs for valid origins. You could pre-populate the list of origins so that it is known at build time, or you could defer that decision to run-time and populate that list with an env var. The latter may be ever so slightly slower, but you also net having your build artifacts be environment agnostic and portable. I def agree that whatever can be determined at build time, should be done when the application is compiled.

As for the performance cost…I think it depends. If you configuration is in an env var or app config, the look up time is negligible. If your config if a network hop away…then yes. At which point you should reach for something like https://hexdocs.pm/elixir/master/Config.Provider.html to resolve the configuration and store it in app config (at run-time).

Where Next?

Popular in Polls Top

AstonJ
Do you have any favourites? (You can pick up to three) poll See post below for details:
New
AstonJ
We had a thread here recently that mentioned webservers in PHP, and it got me curious about the options in the BEAM world and what everyo...
New
AstonJ
Following on from a conversation in the Tidewave thread - how useful do you think AI dev tools are right now and how useful do you think ...
New
AstonJ
I think I’ve used LittleSnitch since my first ever Mac - does anyone else use it or whatever the equivalent is on your OS? What does it ...
New
JEG2
Which topics would you most like to see covered in downloadable Livebook guides (like the How to Train Your Scrappy Programmer series I r...
New
hst337
Do you use hot-reload/recompilation in production? Please note that this poll is only about BEAM’s internal features of runtime upgrades ...
New
germsvel
:wave: hi there! I’m the creator of Testing LiveView. Now that the course is finished, I’m thinking of creating another one. But I’d lik...
New
matt-savvy
Now that the compiler is giving us some reporting about type mismatches, I’m wondering about people’s use of Dialyzer. For anyone on Eli...
New
spicychickensauce
There are many v0 libraries in the elixir echo system, where at least officially, semantic versioning means nothing. However, it seems t...
New
josefrichter
There are two polls and a third question… 1) Displays poll 2) Orientation poll 3) Configuration Please let us know how you are using you...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement