<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 26 Apr 2011, at 19:09, Mike Oxford wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Mmm, tasty!<div><br></div><div>May I offer one small enhancement idea; an alternative-scoped get_env/4 as an alternative?  You could then say have global scopes fall back to local scopes (eg, local only configuration settings) or local scopes fall back to globals (global configuration fallback unless a local is found.)</div></blockquote><div><br></div><div>Interesting. I'd have to think about how that works out conceptually.</div><div><br></div><br><blockquote type="cite">
<div>Also, the documentation states:</div><div><span class="Apple-style-span" style="font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 13px; line-height: 20px; ">"The last instance will be the one that determines the return value."</span></div></blockquote><blockquote type="cite"><div>Is that the last instance defined in "Strategy" or the last instance tried (eg, first instance that matched) ?</div></blockquote><div><br></div><div>That was really meant as "The last instance of {default, Value}", but essentially, the return value will be from the first matching instance, or the last default (initially 'undefined') if nothing matches. The 'error' option is of course special, since it triggers an exception immediately when encountered.</div><div><br></div><div>BR,</div><div>Ulf W</div><div><br></div><br><blockquote type="cite"><div><br></div><div>Thanks for the cool new enhancements!</div><div><br></div>
<div>-mox</div><div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote">On Tue, Apr 26, 2011 at 8:23 AM, Ulf Wiger <span dir="ltr"><<a href="mailto:ulf.wiger@erlang-solutions.com">ulf.wiger@erlang-solutions.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word"><br><div><div>On 25 Apr 2011, at 14:55, Ulf Wiger wrote:</div><br><blockquote type="cite">
<div>I will not present an alternative at this time - although your question gave me an idea. I'll have to think it through a bit first.<br></div></blockquote></div><div><br></div><div>Ok, so here goes:</div><div><br>
</div><div>I have added some functions in gproc (version 0.2.6) for more uniform handling of environment settings:</div><div><br></div><div>gproc:get_env(Scope, App, Key, Alternatives) </div><div><br></div><div><a href="https://github.com/esl/gproc/blob/master/doc/gproc.md#get_env-4" target="_blank">https://github.com/esl/gproc/blob/master/doc/gproc.md#get_env-4</a></div>
<div><br></div><div>checks for a cached value (a global or local gproc property) corresponding to the requested value; if not found, it tries a list of alternatives, including OTP application env vars, os:getenv/1, init:get_argument/1 or even mnesia. Inheriting a parent's, or other process's cached value is also possible. If gproc:get_set_env/4 is used, the result is also cached.</div>
<div><br></div><div>There is also a write-through option, gproc:set_env/5, which modifies the cached value *and* the underlying "original" (e.g. app env, os environment, or mnesia).</div><div><br></div><div><font color="#144FAE"><u><a href="https://github.com/esl/gproc/blob/master/doc/gproc.md#set_env-5" target="_blank">https://github.com/esl/gproc/blob/master/doc/gproc.md#set_env-5</a></u></font></div>
<div><br></div><div>Apart from offering a reasonably uniform and declarative method of fetching environment data, the values are also presented and indexed in a way that simplifies system inspection and debugging. If used consistently, gproc can help notify users of a configuration value that it has changed, simply by calling </div>
<div><br></div><div>gproc:send({p,Scope, {gproc_env, App, Key}}, UpdateMessage).</div><div><br></div><div>according to the principle that processes that rely on static data in non-stop systems, need to be prepared for that data to change over time.</div>
<div><br></div><div>BR,</div><div>Ulf W</div><br><font color="#888888"><div>
<div>Ulf Wiger, CTO, Erlang Solutions, Ltd.</div><div><a href="http://erlang-solutions.com/" target="_blank">http://erlang-solutions.com</a></div><div><br></div><br>
</div>
<br></font></div><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div>Ulf Wiger, CTO, Erlang Solutions, Ltd.</div><div><a href="http://erlang-solutions.com">http://erlang-solutions.com</a></div><div><br></div></span><br class="Apple-interchange-newline">
</div>
<br></body></html>