 (ns thread-load.core
-  (:require [clojure.tools.logging :refer [error]])
+  (:require [clojure.tools.logging :refer [error debug info]])
   (:import
     [java.util ArrayList]
     [java.util.concurrent BlockingQueue ArrayBlockingQueue Executors ExecutorService TimeUnit ThreadPoolExecutor]

(defn get-queue-data! 
  "Blocks till data is available on the queue and returns the data, queue must be BlockingQueue"
  [^BlockingQueue queue]
  (.take queue))

(defn call-on-fail 
  "Only calls init if the return of stop is not :terminate or :fail"

   by one of the consumer functions
   Returns the pool"
  [pool data]
   (when-not (.offer ^BlockingQueue (:queue pool) data 5 TimeUnit/SECONDS)
     (error "Thread load publish queue is full, blocking till a slot becomes available")
     (.put ^BlockingQueue (:queue pool) data)
     (info "Unblocked"))

   pool)

(defn bulk-get!
