[erlang-questions] Use of application environment
Tue Nov 25 10:40:11 CET 2008
I asked myself the same question.
I read the source code of the application_controller module, the get_env function use access to the local ETS table "ac_tab".
>From a performance point of view, I don't think that it's a problem.
Is it considered bad practice to use application environment variables (i.e. application:get_env/2,3) in workers, as opposed to only passing config information via the start()/init() calls? I am finding it tedious as I add more configuration data to the sys.config file, to get_env() the data in a supervisor and then parcel it out to the workers. Also, it becomes a pain to change the values at runtime, whereas if I put a function like this in an affected worker
application:get_env(my_app, my_foo_val, ?SOME_SANE_DEFAULT).
then runtime changes can be made immediately using set_env(), and it becomes much easier to add new config data, but I feel uneasy, almost as if I'm using global variables. From a load point of view, I only do this in places where the value is not used at a high rate.
What is the preferred or recommended (or even most common) practice?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions