                                    {:status :success})
                          lock-ms        (* 60 60 1000)
                          throttle-ms    200
-                         eoq-backoff-ms 2000
-                         lock-ms (* 60 60 1000)
-                         auto-start? true}}]]
-  (let [w (Worker. conn qname (atom false) {:handler        handler
-                                            :lock-ms        lock-ms
-                                            :throttle-ms    throttle-ms
-                                            :eoq-backoff-ms eoq-backoff-ms
-                                            :auto-start?    auto-start?})]
-    (when auto-start? (start w))
-    w))
+                         eoq-backoff-ms (fn [dry-runs] (exp-backoff dry-runs
+                                                        {:max 10000}))
+                         auto-start?    true}}]]
+  (let [w (Worker. conn qname (atom false) (atom 0)
+                   {:handler        handler
+                    :lock-ms        lock-ms
+                    :throttle-ms    throttle-ms
+                    :eoq-backoff-ms eoq-backoff-ms})]
+    (when auto-start? (start w)) w))
 
 (comment
   (def w1 (worker {} "myq"))
   (wcar {} (enqueue "myq" "msg"))
   (stop w1)
   (queue-status {} "myq"))
-
-;;;; Public utils
-
-(defn exp-backoff "Exponential backoff msecs. Useful for retries."
-  [attempt & [{:keys [factor min max]
-               :or   {factor 2000}}]]
-  (let [binary-exp (Math/pow 2 (dec attempt))
-        time (* (+ binary-exp (rand binary-exp)) 0.5 factor)]
-    (long (let [time (if min (clojure.core/max min time) time)
-                time (if max (clojure.core/min max time) time)]
-            time))))
-
-(comment (map #(exp-backoff % {}) (range 10)))
 
 ;;;; Renamed/deprecated
 


          (while @running?
            (try
              (when-let [[mid mcontent attempt :as poll-reply]
                         (wcar conn (dequeue qname opts))]
                (if (= poll-reply "eoq-backoff")
                  (when eoq-backoff-ms (Thread/sleep eoq-backoff-ms))
                  (let [{:keys [status throwable backoff-ms]}
                        (try (handler {:message mcontent :attempt attempt})
                             (catch Throwable t {:status :error
                                                 :throwable t}))]
                    (case status
                      :success (done mid)
                      :retry   (retry mid backoff-ms)
                      :error   (error mid poll-reply throwable)
                      (do (done mid)
                          (timbre/warn (str "Invalid handler status:" status)))))))
              (catch Throwable t
                (timbre/error t "FATAL worker error!")
                (throw t)))

  (:require [clojure.string   :as str]
            [taoensso.carmine :as car :refer (wcar)]
            [taoensso.timbre  :as timbre]))

;;;; Public utils

(defn exp-backoff "Returns binary exponential backoff value."
  [attempt & [{:keys [factor min max]
               :or   {factor 2000}}]]
  (let [binary-exp (Math/pow 2 (dec attempt))
        time (* (+ binary-exp (rand binary-exp)) 0.5 factor)]
    (long (let [time (if min (clojure.core/max min time) time)
                time (if max (clojure.core/min max time) time)]
            time))))

(comment (map #(exp-backoff % {}) (range 10)))

;;;; Implementation

