Guys, what do you think about the following
Let the config be resolvable by a module
config :app, { :resolve_by, App.Config, [
key1: "default",
key2: :other_default
]}
or even just a function
config :app,
key: fn -> "value" end
For performance reasons, `Applicaiton.get_env` should cache the resolved
values at some point, maybe it would be a good idea, to decide when to
cache by the returning value from the resolver, like:
config :app,
key1: fn -> "dynamic" end, # will be called each time `get_env` is called
key2: {:ok, "will be called once"} # will be called once by get_env, then
it will be cached
Let me know what you think
Am Montag, 6. August 2018 21:15:08 UTC+2 schrieb Ivan Yurov:
>
> While playing with deployment I found out that some libraries provide this
> feature that you can put {:system, var} in configuration and then it's
> resolved at runtime. However if it's in my code, I'd have to implement it
> on my own. Wouldn't it be nice if it was supported by Application module by
> default? Something like:
> def get_env(app, key, default \\ nil) do
> case :application.get_env(app, key, default) do
> {:system, var} ->
> System.get_env(var) || default
> rest ->
> rest
> end
> end
>
> Would it make sense?
>
--
You received this message because you are subscribed to the Google Groups
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-core/ae2f5a08-64be-45ce-bea0-4a3d0273896d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.