File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 22
33(def +request+ 0 )
44(def +response+ 1 )
5+ (def +notify+ 2 )
56
67(defn gen-msg-id
78 " Get a unique message id."
1819 [id result]
1920 [1 id nil result])
2021
21-
2222; ; TODO - find better way to get [B type.
2323(def byte-array-type (type (.getBytes " foo" )))
2424
3434
3535; ; ***** Accessor fns *****
3636(def msg-type first )
37+
38+ ; ; Only true for request & response, notify has no id
3739(def id second )
3840
3941(defn request? [msg] (= +request+ (msg-type msg)))
4042(defn response? [msg] (= +response+ (msg-type msg)))
43+ (defn notify? [msg] (= +notify+ (msg-type msg)))
4144
4245(defn value
4346 [msg]
4649
4750(defn method
4851 [msg]
49- {:pre [(request? msg)]}
50- (bytes->str (nth msg 2 )))
52+ {:pre [(or ( request? msg) ( notify? msg) )]}
53+ (bytes->str (nth ( reverse msg) 1 )))
5154
5255(defn params
5356 [msg]
54- {:pre [(or (request? msg) (response? msg))]}
57+ {:pre [(or (request? msg) (response? msg) ( notify? msg) )]}
5558 (last msg))
Original file line number Diff line number Diff line change 1717 " Read messages from the input stream, put them on a channel."
1818 [input-stream]
1919 (let [chan (async/chan 1024 )]
20+ ; ; TODO make these threads w/ loops, since they're handling IO
21+ ; ; might explain the wierd drlog blockages
2022 (async/go-loop
2123 []
2224 (when-let [msg (msgpack/unpack input-stream)]
101103 (let [f (get @method-table (method msg) method-not-found)
102104 result (f msg)]
103105 (send-message-async!
104- component (->response-msg (id msg) result) nil )))
106+ component (->response-msg (id msg) result) nil ))
107+
108+ msg/+notify+
109+ (let [f (get @method-table (method msg) method-not-found)
110+ result (f msg)]))
111+
105112 (recur ))))
106113 component))
You can’t perform that action at this time.
0 commit comments