<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><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">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 class="Apple-style-span" color="#144FAE"><u><a href="https://github.com/esl/gproc/blob/master/doc/gproc.md#set_env-5">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><div>
<div>Ulf Wiger, CTO, Erlang Solutions, Ltd.</div><div><a href="http://erlang-solutions.com">http://erlang-solutions.com</a></div><div><br></div><br class="Apple-interchange-newline">
</div>
<br></body></html>