   (.close client)
   {})
 
+(defn write-handle-exception [event lifecycle lf-kw exception]
+  (cond (= exception org.apache.zookeeper.KeeperException$ConnectionLossException)
+        :restart
+        :else :defer))
+
 (def write-ledger-calls
   {:lifecycle/before-task-start inject-write-ledger-resources
+   :lifecycle/handle-exception write-handle-exception
    :lifecycle/after-task-stop close-write-ledger-resources})
 
 (def HandleWriteCallback

            [onyx.peer.operation :refer [kw->fn]]
            [onyx.types :refer [dec-count! inc-count!]]
            [taoensso.timbre :refer [info error debug fatal]])
  (:import [org.apache.zookeeper KeeperException$BadVersionException]
           [org.apache.bookkeeper.client LedgerHandle LedgerEntry BookKeeper BKException$Code
            BookKeeper$DigestType AsyncCallback$AddCallback]))


                          commit-ch
                          shutdown-ch)))

(defn read-handle-exception [event lifecycle lf-kw exception]
  (cond (= exception org.apache.zookeeper.KeeperException$ConnectionLossException)
        :restart
        :else :defer))

(def read-ledgers-calls
  {:lifecycle/before-task-start inject-read-ledgers-resources
   :lifecycle/handle-exception read-handle-exception
   :lifecycle/after-task-stop close-read-ledgers-resources})

;;;;;;;;;;;;;
