outpace.config
config
The delayed map of explicit configuration values.
defaults
A ref containing the map of symbols for the loaded defconfig vars to their
default values.
defconfig
macro
(defconfig name)
(defconfig name default-val)
(defconfig name doc default-val)
Same as (def name doc-string? init?) except the var's value may be configured
at load-time by this library.
The following additional metadata is supported:
:required - When true, an exception will be thrown if no default nor
configured value is provided.
:validate - A vector of alternating single-arity predicates and error
messages. After a value is set on the var, an exception will be
thrown when a predicate, passed the set value, yields false.
Note: default-val will be evaluated, even if a configured value is provided.
defconfig!
macro
(defconfig! name)
Equivalent to (defconfig ^:required ...).
load-data-readers
(load-data-readers)
Loads the namespaces of data reader Vars whose reader tag symbol has the
'config' namespace.
lookup
(lookup qname)
(lookup qname default-val)
Returns the extracted value if the qname is present, otherwise default-val
or nil.
non-defaulted
A ref containing the set of symbols for the loaded defconfig vars that do
not have a default value.
Optional
protocol
members
provided?
(provided? this)
Returns true if the item should be bound to a config var.
present?
(present? qname)
Returns true if a configuration entry exists for the qname and, if an
Optional value, the value is provided.
read-config
(read-config source)
Reads the config EDN map from a source acceptable to clojure.java.io/reader.
read-edn
(read-edn source)
Returns an EdnVal from a string value. Can be composed with other readers.
read-env
(read-env name)
Returns an EnvVal identified by the specified string name.
read-file
(read-file path)
Returns a FileVal identified by the specified string path.
read-or
(read-or source)
Returns an OrVal from a vector.
read-property
(read-property name)
Returns a PropVal identified by the specified string name.
unbound
(unbound)
Returns the set of symbols for the defconfig vars with neither a default nor
configured value.
valid-key?
(valid-key? k)
Returns true IFF k is acceptable as a key in a configuration map,
i.e., a namespaced symbol.
validate
(validate val var-sym validate-vec)
Throws an ex-info if, for any predicate in validate-vec, (pred val) is false.
The validate-vec must be a vector of alternating single-arity predicate fns
and associated error messages.
Example: [number? "must be a number" even? "must be even"]
The ex-info's ex-data map will contain the following entries:
:pred - the predicate fn that failed
:msg - the associated error message
:sym - the fully-qualified symbol of the config var
:val - the value set on the config var
var-symbol
(var-symbol v)
Returns the namespace-qualified symbol for the var.