I have a Phoenix app that is really just an interface to another application, where I have all of my business logic. I include that application as a dependency in my Phoenix app, so it starts automatically when my Phoenix app starts. (I think this may be referred to as a “poncho” app by some).
The business logic app has one configuration value, which I then have to specify in my Phoenix config. I would like to get out of the business of using config for this and just have apps that use my business logic app pass it a value at runtime when it starts.
Within the context of a supervision tree I understand how to specify a function and arguments to call in a child spec, and I understand how to pass arguments to the main application via the
mod keyword in the
start/2 function in
mix.exs, but here I am really trying to figure out how to specify the arguments that will be passed to
start/2 for a application dependency (not just a worker process) when the dependency is started.
Or if there are other approaches to replace compile-time dependency configuration with something at runtime in this context I am open to those. I am not that excited about using
System.get_env because I would rather not have to manage yet another source of configuration values.
I have also read Michał Muskała’s article on this topic, and I get the sense he may be recommending some kind of callback approach in this situation, but it wasn’t explained in enough detail for me to quite get it.