             [onyx.peer.virtual-peer :refer [virtual-peer]]
             [onyx.messaging.acking-daemon :refer [acking-daemon]]
             [onyx.messaging.messenger-buffer :refer [messenger-buffer]]
-            [onyx.messaging.http-kit :refer [http-kit-websockets]]
-            [onyx.messaging.aeron :refer [aeron]]
-            [onyx.messaging.netty-tcp :refer [netty-tcp-sockets]]
             [onyx.log.zookeeper :refer [zookeeper]]
             [onyx.log.commands.prepare-join-cluster]
             [onyx.log.commands.accept-join-cluster]


(def peer-components [:log :messenger-buffer :messenger :acking-daemon :virtual-peer])

(def messenger
  {:http-kit-websockets http-kit-websockets
   :netty-tcp netty-tcp-sockets
   :aeron aeron})

(defn rethrow-component [f]
  (try

     #(component/stop-system this peer-components))))

(defn messenger-ctor [config]
  (let [rets ((messenger (:onyx.messaging/impl config)) config)]
    (when-not rets
      (throw (ex-info "Could not find Messaging implementation" {:impl (:onyx.messaging/impl config)})))
    rets))
