I believe the community is moving away from the {:system, var} pattern,
though some libraries will continue to support it. I believe the short term
solution being worked on is to allow your config to run at runtime. Which
would mean you could just do System.get_env/1. The longer term push is
likely to encourage less configuration in config and move more of it into
the supervisor inits.

Allen Madsen
http://www.allenmadsen.com


On Mon, Aug 6, 2018 at 5:33 PM Ivan Yurov <[email protected]> wrote:

> I agree that in general this is not something that should be defined in
> the language core or the standard lib.
> However, configuration (application env) is already managed by elixir, and
> this pattern to access system env var is a widely used by the libraries, so
> this might appear confusing for someone, that they set {:system, var} and
> it doesn't magically get resolved as it does with many libraries. :)
> Also, there's only one case when it really breaks, — when someone really
> wants to return {:system, something} on Application.get_env call, as you
> have pointed out. But why would they?
>
> Thanks, I'll take a closer look at Confex it seems to be doing exactly
> what I want. Even though there's a bit more of a boilerplate.
>
> On Monday, August 6, 2018 at 1:55:30 PM UTC-7, OvermindDL1 wrote:
>>
>> But what if I want to read it from a data store, or the database, or a
>> variety of other places.
>>
>> A whole configuration handling overhaul has been discussed on the forums
>> not long ago:
>>
>> https://elixirforum.com/t/proposal-moving-towards-discoverable-config-files/14302
>>
>> For now, https://hex.pm/packages/confex is a decent'ish shim that works
>> well enough for build-time configurations though.  :-)
>>
>> But overall, things like that seem more suited for a configuration
>> library (that should be included in Elixir once it is sufficiently generic
>> enough and staged enough), though environment variables are common for the
>> configs, that doesn't mean that someone really doesn't just want `{:system,
>> var}` returned straight though, as can be the case..
>>
>> :-)
>>
>>
>> On Monday, August 6, 2018 at 1:15:08 PM UTC-6, Ivan Yurov wrote:
>>>
>>> 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/b4a347ae-baa1-4d79-b906-4108a414b33c%40googlegroups.com
> <https://groups.google.com/d/msgid/elixir-lang-core/b4a347ae-baa1-4d79-b906-4108a414b33c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAK-y3Cv8BzaRD039ZCfGtqKDEtUEpHER7Ggf8_veOMHn1ARXvw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to