Skip to content

Commit 810d5e6

Browse files
committed
arity-1 function in streaming-buffer transducer (so that it would work on finite collections as well)
1 parent b41f312 commit 810d5e6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Clojure-Websockets/src/clj/birdwatch/twitterclient/processing.clj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
(defn- streaming-buffer []
2424
(fn [step]
2525
(let [buff (atom "")]
26-
(fn [r x]
26+
(fn
27+
([r] (step r))
28+
([r x]
2729
(let [json-lines (-> (str @buff x) (insert-newline) (str/split-lines))
2830
to-process (butlast json-lines)]
2931
(reset! buff (last json-lines))
30-
(if to-process (reduce step r to-process) r))))))
32+
(if to-process (reduce step r to-process) r)))))))
3133

3234
(defn- tweet? [data]
3335
"Checks if data is a tweet. If so, pass on, otherwise log error."
@@ -50,3 +52,7 @@
5052

5153
(defn ex-handler [ex]
5254
(log/error "Exception while processing chunk" ex))
55+
56+
57+
58+

0 commit comments

Comments
 (0)