 (ns com.frereth.server.system
   (:require
+   [clojure.core.async :as async]
+   [com.frereth.common.async-zmq :as async-zmq]
    [com.frereth.common.util :as util]
    [com.stuartsierra.component :as component]
    [component-dsl.system :as cpt-dsl]
    [schema.core :as s]
    [taoensso.timbre :as log])
-  (import [com.stuartsierra.component SystemMap]))
+  (import [com.frereth.common.async_zmq EventPair EventPairInterface]
+          [com.stuartsierra.component SystemMap]))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Schema

    {;; Almost definitely want to maximize this thread count
     ;; Although that really depends on the environment.
     ;; It makes sense for a production server.
     ;; For a local one...probably not so much
     :context {:thread-count (-> (util/core-count) dec (max 1))}

     :action-socket (assoc-in default-sock [:url :port] 7841)
     :auth-socket (assoc-in default-sock [:url :port] 7843)
     :control-socket (assoc default-sock
                            :url {:protocol :inproc
                                  :address (name (gensym))})}))

(defn structure []
  '{:action-socket com.frereth.common.zmq-socket/ctor
    :auth-socket com.frereth.common.zmq-socket/ctor
    :context com.frereth.common.zmq-socket/ctx-ctor
    :control-socket com.frereth.common.zmq-socket/ctor
    :done com.frereth.server.sentinal/ctor
    :logger com.frereth.server.logging/ctor
    ;; For auth


(defn dependencies []
  {:action-socket {:ctx :context}
   :action-loop-interface {:ex-sock :action-socket}
   :action-loop {:interface :action-loop-interface}
   :auth-socket {:ctx :context}
   :auth-loop-interface {:ex-sock :auth-socket}
   :auth-loop {:ex-sock :auth-socket, :interface :auth-loop-interface}
   :control-socket {:ctx :context}
   :control-loop-interface {:ex-sock :control-socket}
   :control-loop {:ex-sock :action-socket, :interface :action-loop-interface}
   :principal-manager [:control-socket]})

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