[erlang-questions] separating application from gen server

Adam Kelly cthulahoops@REDACTED
Wed Nov 28 19:31:17 CET 2007

On Nov 28, 2007 1:14 PM, Ludovic Coquelle <lcoquelle@REDACTED> wrote:
> Usually I let the application get the config variables, and start the
> gen_server with the good params. So that only application manage its config
> (through a dedicated module, such that it is easy to move the config from
> env to DB or other file ... I did need to parse a ini file once :( ).
> Something in the line of:

Yes, that's my rule as well.  gen_servers and supervisors aren't allowed query
the application configuration.  I end up with this pattern all the time:


start(_Type, _Args) ->
    Options = application:get_all_env(myapp),

Then I can pretty much always test gen_servers and supervisors in isolation
without running up the whole application, recombine them in different ways
to form different applications, etc.

There's some complications (how do you deal with configuration changes
at run-time?) but it basically works well.

Is this a common strategy?


More information about the erlang-questions mailing list