This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-28
Channels
- # aleph (1)
- # announcements (16)
- # bangalore-clj (1)
- # beginners (78)
- # cider (109)
- # clara (3)
- # cljdoc (6)
- # cljsjs (3)
- # clojure (209)
- # clojure-dev (11)
- # clojure-europe (1)
- # clojure-france (9)
- # clojure-italy (13)
- # clojure-nl (3)
- # clojure-spain (2)
- # clojure-spec (19)
- # clojure-uk (50)
- # clojurescript (41)
- # clojutre (2)
- # core-async (45)
- # cursive (2)
- # datomic (14)
- # emacs (6)
- # figwheel-main (1)
- # fulcro (101)
- # graalvm (1)
- # graphql (3)
- # jobs-discuss (3)
- # kaocha (12)
- # leiningen (8)
- # music (4)
- # off-topic (47)
- # parinfer (8)
- # pathom (17)
- # pedestal (53)
- # re-frame (47)
- # reagent (22)
- # reitit (4)
- # shadow-cljs (49)
- # tools-deps (87)
I'm using Aleph's client to connect to a push feed. It uses a chunked response encoding to push out JSON objects. I'm using manifold.stream/stream->seq
to convert the chunks into a sequences. Effectively, something like this:
(require '[manifold.stream :as ms])
(require '[aleph.http :as http])
(defn connect-to-push-stream
[{:keys [::process-fn ::push-url]}]
(m-d/chain (http/get push-url
{:pool (http/connection-pool
{:connection-options {:raw-stream? true}})})
:body
ms/stream->seq
;; TODO transform to seq of maps from json objects
;; Apply process-fn to each map created from the json object
#(map process-fn %)))
Of course, the items in the sequence are not the complete json payloads. I can iterate over the sequence and look for the CRLF endings to combine them.
However, I wasn't sure if there is anything Aleph provides that does this out of the box. I looked at the coerce-json-response
middleware, but it doesn't look like it works with a push feed.