Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Each handle cal calls get_all_env for two settings can be moved in init phase and stored in state.. #23

Open
linearregression opened this issue Jan 29, 2016 · 3 comments

Comments

@linearregression
Copy link

For every subscribe call it is calling application:gen_all_env..., though I suspect subscribe call is not that frequent.

Would moving get_all_env to init phase and store in state be better?
How about getting the config settings before starting the worker. If getting settings error-ed out(I assume that is essential info for worker to work), supervisor then does not need to start worker then restart etc.

File: elixometer/lib/elixometer.ex

 def handle_call({:subscribe, name}, _caller, state) do
      cfg = Application.get_all_env(:elixometer) <-----
      reporter = cfg[:reporter]   # <--- looks like this is relatively constant
      interval = cfg[:update_frequency]  # <--  looks like this is relatively constant
@scohen
Copy link
Collaborator

scohen commented Feb 2, 2016

We could probably do something even smarter, like doing that during compile and binding it into a module attribute.

@zachdaniel
Copy link
Contributor

zachdaniel commented Apr 30, 2017

@scohen you don't want to do that, because then people using releases won't be able to use environment variables to change this configuration.

@zorbash
Copy link
Contributor

zorbash commented Jun 30, 2017

What about benchmarking it, to find out if it's worth optimising it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants