Improve memory efficiency by writing more frequently to back-channel.
This commit is contained in:
parent
68440ee178
commit
68d2ebc633
|
@ -1,10 +1,10 @@
|
||||||
(defproject net.thegeez/clj-browserchannel-jetty-adapter "0.0.7"
|
(defproject net.thegeez/clj-browserchannel-jetty-adapter "0.0.8"
|
||||||
:description "Jetty async adapter for BrowserChannel"
|
:description "Jetty async adapter for BrowserChannel"
|
||||||
:url ""
|
:url ""
|
||||||
:dependencies [[ring/ring-core "1.3.1"]
|
:dependencies [[ring/ring-core "1.3.1"]
|
||||||
[ring/ring-servlet "1.3.1"]
|
[ring/ring-servlet "1.3.1"]
|
||||||
[org.eclipse.jetty/jetty-server "8.1.16.v20140903"];; includes ssl
|
[org.eclipse.jetty/jetty-server "8.1.16.v20140903"];; includes ssl
|
||||||
[net.thegeez/clj-browserchannel-server "0.2.0"]]
|
[net.thegeez/clj-browserchannel-server "0.2.1"]]
|
||||||
:profiles {:provided
|
:profiles {:provided
|
||||||
{:dependencies
|
{:dependencies
|
||||||
[[org.clojure/clojure "1.6.0"]]}})
|
[[org.clojure/clojure "1.6.0"]]}})
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
(defproject net.thegeez/clj-browserchannel-server "0.2.0"
|
(defproject net.thegeez/clj-browserchannel-server "0.2.1"
|
||||||
:description "BrowserChannel server implementation in Clojure"
|
:description "BrowserChannel server implementation in Clojure"
|
||||||
:dependencies [[ring/ring-core "1.3.1"]
|
:dependencies [[ring/ring-core "1.3.1"]
|
||||||
[org.clojure/data.json "0.2.5"]]
|
[org.clojure/data.json "0.2.5"]]
|
||||||
|
|
|
@ -328,6 +328,8 @@
|
||||||
;; this is used for diagnostic purposes by the client
|
;; this is used for diagnostic purposes by the client
|
||||||
bytes-sent])
|
bytes-sent])
|
||||||
|
|
||||||
|
(defn to-pair [p] (str "[" (first p) "," (second p) "]"))
|
||||||
|
|
||||||
(defrecord Session [;; must be unique
|
(defrecord Session [;; must be unique
|
||||||
id
|
id
|
||||||
|
|
||||||
|
@ -436,11 +438,10 @@
|
||||||
(try
|
(try
|
||||||
;; buffer contains [[1 json-str] ...] can't use
|
;; buffer contains [[1 json-str] ...] can't use
|
||||||
;; json-str which will double escape the json
|
;; json-str which will double escape the json
|
||||||
(let [data (str "["
|
|
||||||
(str/join "," (map (fn [[n d]] (str "[" n "," d "]")) to-flush))
|
(doseq [p to-flush #_(next to-flush)]
|
||||||
"]")]
|
(write (:respond back-channel) (str "[" (to-pair p) "]")))
|
||||||
;; write throws exception when the connection is closed
|
|
||||||
(write (:respond back-channel) data))
|
|
||||||
;; size is an approximation
|
;; size is an approximation
|
||||||
(let [this (let [size (reduce + 0 (map count (map second to-flush)))]
|
(let [this (let [size (reduce + 0 (map count (map second to-flush)))]
|
||||||
(-> this
|
(-> this
|
||||||
|
|
Reference in a new issue