/
config.clj
27 lines (22 loc) · 1.28 KB
/
config.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(ns dirac.agent.config
(:require [dirac.utils :refer [deep-merge-ignoring-nils]]
[dirac.config :refer [read-env-config]]))
(def env-config-prefix "dirac-agent")
; you can override individual config keys via ENV variables, for example:
; DIRAC_AGENT/LOG_LEVEL=debug or DIRAC_AGENT/NREPL_SERVER/PORT=7777
;
; see https://github.com/binaryage/env-config
(def default-config
{:log-level "WARN" ; OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL
:max-boot-trials 10
:initial-boot-delay 1000
:delay-between-boot-trials 500
:nrepl-server {:host "localhost"
:port 8230}
:nrepl-tunnel {:host "localhost"
:port 8231}})
; -- config evaluation ------------------------------------------------------------------------------------------------------
(defn get-effective-config* [& [config]]
(let [env-config (read-env-config env-config-prefix)]
(deep-merge-ignoring-nils default-config env-config config)))
(def ^:dynamic get-effective-config (memoize get-effective-config*)) ; assuming env-config is constant