akoutmos
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)
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
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).
Popular in Polls
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
- #security
- #hex









