On 14 August 2014 17:36, Constantine Vetoshev <gepar...@gmail.com> wrote:

>
> 2. Loading env files in the REPL, and modifying the environment at runtime
> in general. Environ only handles loading variables when it loads itself,
> and has no provision for modifying them except by restarting the Clojure
> process.
>
> You can still modify the env var with alter-var-root. You don't need to
restart the REPL to change the value of a var, even a non-dynamic one.

In general though, you're correct. With Environ, I wanted to distinguish
between the execution environment and the application configuration. The
environment is static for the duration of the process, but the
configuration is user-defined and can be changed at will.

The idea is that you have a configuration that is *based* on the
environment, but not the same as the environment. For example:

(def system-config
  {:server {:port (Integer. (env :port "3000"))}})

By making it separate, the configuration can make use of nested maps and
non-string data types, like using an integer for the port number. You can
also set default options, and add functions to parse or manipulate
environment variables into more useful forms.

If you like, you could also make this configuration dynamic, or place it
into an atom.

Another advantage to this approach is that you can always reset it back to
the environment options if you mess anything up. If the env var is static
for the duration of the REPL session, you can rebuild the configuration
from the environment.

- James

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to