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
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
AstonJ
Do you use Dialyzer/Dialyxir in your Elixir projects? poll If you only use it in some of them, which ones? If you don’t use it, why not...
New
New
AstonJ
What is your primary dev OS? And is there any software you’d like to recommend that could make development easier? (Apart from the code e...
New
AstonJ
Curious whether you remap your Caps Lock key.. Do you remap your Caps Lock key? poll I have no idea what Globe is btw, just seen it in t...
New
AstonJ
Curious whether you’re using wired or wireless to connect to your main working machine to the internet - if you have any specific reasons...
New
matt-savvy
I see some people adopt this convention when naming fields or variables where the value is a boolean. I personally see this as an antipat...
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
akoutmos
I was wondering how people are handling run-time configuration of their Plugs in their Phoenix applications as of today: poll I am also ...
New

Other popular topics Top

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
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
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
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement