   [app opts]
   (let [opts (merge default-options opts)]
     (State. app nil (:retries opts) false opts)))
+
+(declare retry-request)
 
 (defn- attempt-request
   [state downstream request current-state]

                (if (< 0 retry)
                  (timeout
                   (first (.retries current-state))
                   #(attempt-request state downstream request current-state*))
                  (attempt-request state downstream request current-state*)))))

           (when-let [current-downstream @current-downstream-atom]
             (current-downstream evt val))

    :as upstream
    (swap! state #(assoc % :upstream upstream))
    (upstream :request request))))

(defn- retry-request
  [state downstream request current-state]
  (log/info (str "retrying request: " (request-url request)))
  (attempt-request state downstream request current-state))

(defn retry
  ([app] (retry app {}))
