Core functions required by a Duct application.
Core functions required by a Duct application.
(add-shutdown-hook key func)
Set a function to be executed when the current process shuts down. The key
argument should be unique, and is used in remove-shutdown-hook
.
Set a function to be executed when the current process shuts down. The key argument should be unique, and is used in [[remove-shutdown-hook]].
(await-daemons system)
If the supplied system has keys deriving from :duct/daemon
, block the
current thread indefinitely and add a shutdown hook to halt the system.
If the supplied system has keys deriving from `:duct/daemon`, block the current thread indefinitely and add a shutdown hook to halt the system.
(build-config config)
(build-config config profiles)
Build an Integrant configuration from a configuration of modules. A
collection of profile keys may optionally be supplied that govern which
profiles to use (see profile-keys
). Omitting the profiles or using the
:all keyword in their stead will result in all keys being used.
Build an Integrant configuration from a configuration of modules. A collection of profile keys may optionally be supplied that govern which profiles to use (see [[profile-keys]]). Omitting the profiles or using the :all keyword in their stead will result in all keys being used.
(exec-config config)
(exec-config config profiles)
(exec-config config profiles keys)
Build, prep and initiate a configuration of modules, then block the thread
(see await-daemons
). By default it only runs profiles derived from
:duct.profile/prod
and keys derived from :duct/daemon
.
This function is designed to be called from -main
when standalone operation
is required.
Build, prep and initiate a configuration of modules, then block the thread (see [[await-daemons]]). By default it only runs profiles derived from `:duct.profile/prod` and keys derived from `:duct/daemon`. This function is designed to be called from `-main` when standalone operation is required.
(fold-modules system)
Fold a system map of modules into an Integrant configuration. A module is a pure function that transforms a configuration map. The modules are traversed in dependency order and applied to iteratively to a blank map in order to build the final configuration.
Fold a system map of modules into an Integrant configuration. A module is a pure function that transforms a configuration map. The modules are traversed in dependency order and applied to iteratively to a blank map in order to build the final configuration.
(load-hierarchy)
Search the base classpath for files named duct_hierarchy.edn
, and use them
to extend the global derive
hierarchy. This allows a hierarchy to be
constructed without needing to load every namespace.
The duct_hierarchy.edn
file should be an edn map that maps child keywords
to vectors of parents. For example:
{:example/child [:example/father :example/mother]}
This is equivalent to writing:
(derive :example/child :example/father)
(derive :example/child :example/mother)
This function should be called once when the application is started.
Search the base classpath for files named `duct_hierarchy.edn`, and use them to extend the global `derive` hierarchy. This allows a hierarchy to be constructed without needing to load every namespace. The `duct_hierarchy.edn` file should be an edn map that maps child keywords to vectors of parents. For example: {:example/child [:example/father :example/mother]} This is equivalent to writing: (derive :example/child :example/father) (derive :example/child :example/mother) This function should be called once when the application is started.
(merge-configs & configs)
Intelligently merge multiple configurations. Uses meta-merge and will merge configurations in order from left to right. Generic top-level keys are merged into more specific descendants, if the descendants exist.
Intelligently merge multiple configurations. Uses meta-merge and will merge configurations in order from left to right. Generic top-level keys are merged into more specific descendants, if the descendants exist.
(parse-keys args)
Parse config keys from a sequence of command line arguments.
Parse config keys from a sequence of command line arguments.
(prep-config config)
(prep-config config profiles)
Load, build and prep a configuration of modules into an Integrant configuration that's ready to be initiated. This function loads in relevant namespaces based on key names, so is side-effectful (though idempotent).
Load, build and prep a configuration of modules into an Integrant configuration that's ready to be initiated. This function loads in relevant namespaces based on key names, so is side-effectful (though idempotent).
(profile-keys config profiles)
Return a collection of keys for a configuration that excludes any profile
not present in the supplied colleciton of profiles. Profiles may be specified
as namespaced keywords, or as un-namespaced keywords, in which case only the
name will matched (e.g. :dev
will match :duct.profile/dev
). If the :all
keyword is supplied instead of a profile collection, all keys are returned.
Return a collection of keys for a configuration that excludes any profile not present in the supplied colleciton of profiles. Profiles may be specified as namespaced keywords, or as un-namespaced keywords, in which case only the name will matched (e.g. `:dev` will match `:duct.profile/dev`). If the :all keyword is supplied instead of a profile collection, all keys are returned.
(read-config source)
(read-config source readers)
Read an edn configuration from a slurpable source. An optional map of data readers may be supplied. By default the following five readers are supported:
#duct/env
: an environment variable, see duct.core.env/env
#duct/include : substitute for a configuration on the classpath
#duct/resource
: a resource path string, see resource
#ig/ref : an Integrant reference to another key
#ig/refset : an Integrant reference to a set of keys
Read an edn configuration from a slurpable source. An optional map of data readers may be supplied. By default the following five readers are supported: #duct/env : an environment variable, see [[duct.core.env/env]] #duct/include : substitute for a configuration on the classpath #duct/resource : a resource path string, see [[resource]] #ig/ref : an Integrant reference to another key #ig/refset : an Integrant reference to a set of keys
(remove-shutdown-hook key)
Remove a shutdown hook identified by the specified key.
Remove a shutdown hook identified by the specified key.
(resource path)
Return an record that represents a resource on the classpath, compatible with
clojure.java.io
functions like reader
, input-stream
and as-url
. When
printed, the record returns a string tagged with #duct/resource
. This makes
it more useful than a bare URL object when printing a configuration. If the
resource does not exist, nil
is returned.
Return an record that represents a resource on the classpath, compatible with `clojure.java.io` functions like `reader`, `input-stream` and `as-url`. When printed, the record returns a string tagged with `#duct/resource`. This makes it more useful than a bare URL object when printing a configuration. If the resource does not exist, `nil` is returned.
A path to place generated files in. Typically used by compilers. Can be set
via the duct.target.path
system property.
A path to place generated files in. Typically used by compilers. Can be set via the `duct.target.path` system property.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close