 (ns com.puppetlabs.puppetdb.config
+  "Centralized place for reading a user-defined config INI file, validating,
+   defaulting and converting into a format that can startup a PuppetDB instance.
+
+   The schemas in this file define what is expected to be present in the INI file
+   and the format expected by the rest of the application."
   (:import [java.security KeyStore])
   (:require [clojure.tools.logging :as log]
             [puppetlabs.kitchensink.ssl :as ssl]

            [schema.core :as s]
            [com.puppetlabs.puppetdb.schema :as pls]))

(def half-the-cores
  "Half the number of CPU cores, used for defaulting the number of
   command processors"

      (/ 2)
      (int)
      (max 1)))

(def command-processing-in
  "Schema for incoming command processing config (user defined) - currently incomplete"
  {(s/optional-key :dlo-compression-threshold) (pls/defaulted-maybe s/String "1d")
   (s/optional-key :threads) (pls/defaulted-maybe s/Int half-the-cores)
   (s/optional-key :store-usage) (s/maybe s/Int)
   (s/optional-key :temp-usage) (s/maybe s/Int)})

(def command-processing-out
  "Schema for parsed/processed command processing config - currently incomplete"
  {:dlo-compression-threshold pls/Period
   :threads s/Int
   (s/optional-key :store-usage) (s/maybe s/Int)
   (s/optional-key :temp-usage) (s/maybe s/Int)})

(defn configure-commandproc-threads
  "Update the supplied config map with the number of
