This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-19
Channels
- # aleph (11)
- # aws (1)
- # beginners (14)
- # bitcoin (1)
- # boot (41)
- # cider (6)
- # cljs-dev (1)
- # cljsrn (13)
- # clojure (138)
- # clojure-italy (10)
- # clojure-nl (1)
- # clojure-poland (2)
- # clojure-russia (62)
- # clojure-sg (2)
- # clojure-spec (31)
- # clojure-uk (51)
- # clojurescript (109)
- # core-matrix (1)
- # core-typed (1)
- # cursive (63)
- # datomic (10)
- # emacs (9)
- # euroclojure (1)
- # hoplon (112)
- # immutant (16)
- # jobs (2)
- # lumo (5)
- # off-topic (14)
- # om (54)
- # onyx (17)
- # parinfer (23)
- # pedestal (2)
- # re-frame (41)
- # ring-swagger (23)
- # spacemacs (9)
- # specter (10)
- # uncomplicate (5)
- # vim (1)
Can someone tell me why I need to call realize-each
here?
I suppose it means that my requests are all realized and kept into memory until further processing,
which is something I am trying to avoid.
(s/stream->seq
(s/map (fn [res]
(println (type res)) ;; manifold.deferred.Deferred if not realize-each
(select-keys res [:request-time :connection-time :status]))
(s/realize-each ;; why do I need this?
(s/map (fn [u]
(println "HTTP REQ TO " u)
(aleph.http/get u {:throw-exceptions? false}))
(s/buffer 50
(s/->source
[""
""
""]))))))
Also, I note that the following works:
@(d/chain (aleph.http/get "")
#(select-keys % [:request-time :status]))
It looks like https://github.com/ztellman/manifold/blob/master/docs/stream.md has a hint:
The value returned by the callback for connect-via provides backpressure - if a deferred value is returned, further messages will not be passed in until the deferred value is realized.
but I don’t understand itThat looks closer to what I want:
(time (doall (s/stream->seq
(s/map (fn [res]
(select-keys res [:request-time :connection-time :status]))
(s/realize-each
(s/map (fn [u]
(println "HTTP REQ TO " u)
(aleph.http/get u {:throw-exceptions? false}))
(s/throttle 1
(s/buffer 50
(s/->source
(map #(str " " %) (range 1 10))
)))))))))