            (clojure.lang Atom))
   (:require [clojure.tools.logging :as log]
             [me.raynes.fs :as fs]
-            [schema.core :as schema]))
+            [schema.core :as schema]
+            [puppetlabs.kitchensink.core :as ks]))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Definitions
+
+(def default-pool-size
+  "The default size of each JRuby pool."
+  (+ 2 (ks/num-cpus)))
 
 (def illegal-env-names
   "These environment names are not allowed by Puppet."


(def PoolDefinition
  {:environment schema/Str
   :size schema/Int})

(def PoolConfig
  "Schema defining the config map for the JRubyPuppet pooling functions.

  create-pool-from-config :- PoolData
  "Create a new PoolData based on the config input."
  [{:keys [environment size]} :- PoolDefinition]
  (let [size (if size size
                      default-pool-size)]
    {:environment  (keyword environment)
     :pool         (instantiate-free-pool size)
     :size         size
     :initialized? false}))

(schema/defn ^:always-validate
  add-pool-from-config :- PoolsMap
