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

getclj

(get k)
(get k not-found)

Returns the config value for the given key. If a not-found argument is passed, that will be returned if no value is found, otherwise nil.

Returns the config value for the given key. If a not-found argument is
passed, that will be returned if no value is found, otherwise nil.
sourceraw docstring

get-allclj

(get-all)

Returns the entire config map.

Returns the entire config map.
sourceraw docstring

load!clj

(load!)
(load! env-key)

Loads the config. Unless you'd like to specify your own env-key, you won't need to call this directly as the config will be automatically loaded on first access.

Loads the config. Unless you'd like to specify your own env-key,
you won't need to call this directly as the config will be
automatically loaded on first access.
sourceraw docstring

loaded?clj

(loaded?)

Tests whether the config has been loaded.

Tests whether the config has been loaded.
sourceraw docstring

set!clj

(set! k val)

Sets the config value for the given key. This is useful when debugging in the repl.

Sets the config value for the given key. This is useful when
debugging in the repl.
sourceraw docstring

unload!clj

(unload!)

Unloads the config. This exists mainly to ease testing and should very rarely, if ever, be called in your app.

Unloads the config. This exists mainly to ease testing
and should very rarely, if ever, be called in your app.
sourceraw docstring

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

× close