Liking cljdoc? Tell your friends :D

conf.core

Library to read configuration values from edn resources, environment variables, and Java system properties.

Values are loaded in this order, with later values overriding previous values:

  • /resources/conf/base.edn
  • /resources/conf/default.edn
  • /resources/conf/defaults/$CURRENT.edn
  • /resources/conf/$CURRENT.edn
  • Environment variables
  • Java properties

The current environment is determined by the special environment variable, the 'env-key', CONF_ENV (or the Java property conf.env). The value of the env-key determines the name of additional edn resources to load. First /resources/conf/defaults/$CURRENT.ednis loaded and then /resources/conf/$CURRENT.edn is loaded (if they exist). Values set in these files will take precedence over those set in the previous configs. For example, to run a program in a production configuration, you might run the command: CONF_ENV=prod lein run. This would load the base config file, /resources/conf/defaults/prod.edn, and /resources/conf/prod.edn, with the latter files taking precedence over the earlier ones. Note that the value of CONF_ENV can be an arbitrary string; you can name the environment-specific config resources however you like.

As listed above, environment variables are also merged into the config. These take a higher precedence and can override any file's value. Names of environment variables are normalized from UPPER_UNDERSCORE_CASE strings to more Clojure-esque lower-dash-case keywords.

Finally, Java system properties are also merged into the config. These take the highest precedence of all, and can override any other config value. Property names are normalized from lower.dot.case to the typical lower-dash-case, just like environment variables.

If for some reason you don't like the default env-key, CONF_ENV, you're free to choose your own by calling load! with an additional argument.

Library to read configuration values from edn resources,
environment variables, and Java system properties.

Values are loaded in this order, with later values overriding
previous values:

 - `/resources/conf/base.edn`
 - `/resources/conf/default.edn`
 - `/resources/conf/defaults/$CURRENT.edn`
 - `/resources/conf/$CURRENT.edn`
 - Environment variables
 - Java properties

The current environment is determined by the special environment
variable, the 'env-key', `CONF_ENV` (or the Java property
`conf.env`). The value of the env-key determines the name of
additional edn resources to load.  First
`/resources/conf/defaults/$CURRENT.edn`is loaded and then
`/resources/conf/$CURRENT.edn` is loaded (if they exist).  Values
set in these files will take precedence over those set in the
previous configs. For example, to run a program in a production
configuration, you might run the command: `CONF_ENV=prod lein
run`. This would load the base config file,
`/resources/conf/defaults/prod.edn`, and `/resources/conf/prod.edn`,
with the latter files taking precedence over the earlier ones. Note
that the value of `CONF_ENV` can be an arbitrary string; you can
name the environment-specific config resources however you like.

As listed above, environment variables are also merged into the
config. These take a higher precedence and can override any file's
value. Names of environment variables are normalized from
UPPER_UNDERSCORE_CASE strings to more Clojure-esque lower-dash-case
keywords.

Finally, Java system properties are also merged into the
config. These take the highest precedence of all, and can override
any other config value.  Property names are normalized from
lower.dot.case to the typical lower-dash-case, just like environment
variables.

If for some reason you don't like the default env-key, `CONF_ENV`, you're free
to choose your own by calling `load!` with an additional argument.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close