I need to distribute some sort of static configuration through my application. What is the best practice to do that?
I see three options:
- Call
application:get_env
directly whenever a module requires to get configuration value.- Plus: simpler than other options.
- Minus: how to test such modules without bringing the whole application thing up?
- Minus: how to start certain module with different configuration (if required)?
- Pass the configuration (retrieved from
application:get_env
), to application modules during start-up.- Plus: modules are easier to test, you can start them with different configuration.
- Minus: lot of boilerplate code. Changing the configuration format requires fixing several places.
- Hold the configuration inside separate configuration process.
- Plus: more-or-less type-safe approch. Easier to track where certain parameter is used and change those places.
- Minus: need to bring up configuration process before running the modules.
- Minus: how to start certain module with different configuration (if required)?