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>
<div><br></div><div>Also, the documentation states:</div><div><meta charset="utf-8"><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>
<div><br></div><div>Is that the last instance defined in "Strategy" or the last instance tried (eg, first instance that matched) ?</div><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>