Closed oubiwann closed 8 years ago
So far:
(defmulti handle-msg
""
(comp :type last vector))
(defmethod handle-msg :subscribed
[state msg]
(log/debug "Got SUBSCRIBED message.")
(log/trace msg))
(defmethod handle-msg :heartbeat
[state msg]
(log/debug "Got HEARTBEAT message.")
(log/trace msg))
(defmethod handle-msg :offers
[state msg]
(log/debug "Got OFFERS message.")
(log/trace msg))
(defmethod handle-msg :default
[state msg]
(log/error "Unknown type ...")
(log/trace msg))
These will be called (at least initially) in the following manner:
(defn read-stream [ch stream]
(async/go-loop []
(async/put! ch (recordio/next! stream :json))
(recur)))
(def response (master/subscribe c framework-info))
(def stream (:body response))
(def ch (async/chan))
(async/reduce handle-msg {:client c :stream stream :channel ch} ch)
(read-stream ch stream)
As such, it might make sense to:
meson.scheduler.handlers
default
(async/reduce handlers/default {:client c :stream stream :channel ch} ch)
Tasks: