Passing arguments around is sometimes a pain while working with Elixir. However, for Web apps, since each request runs in its own process, we should be able to stick bits of context into the Process storage. For instance, we could stick the
role and things which are may be needed across the app.
So, you would do this at the beginning of the request (maybe in a plug)
And in other modules where we need an api key just do
Process.get :api_key, This may also be a good place to store tenant info in multi tenant apps.
I feel this goes against the purity of functional programming, but seems like it could have practical use cases. One gotcha would be to make sure that we pass the arguments when things cross a process boundary, but that should be ok.
Would love to hear what you guys think about this