This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-16
Channels
- # bangalore-clj (8)
- # beginners (78)
- # boot (68)
- # cljs-dev (32)
- # cljsrn (43)
- # clojars (2)
- # clojure (147)
- # clojure-italy (4)
- # clojure-nl (2)
- # clojure-quebec (1)
- # clojure-russia (19)
- # clojure-spec (17)
- # clojure-uk (25)
- # clojurescript (98)
- # clr (2)
- # core-async (14)
- # cursive (5)
- # datascript (1)
- # datomic (23)
- # emacs (4)
- # hoplon (8)
- # jobs (4)
- # kekkonen (1)
- # lein-figwheel (9)
- # off-topic (2)
- # om (2)
- # om-next (9)
- # onyx (4)
- # planck (2)
- # re-frame (14)
- # ring-swagger (3)
- # untangled (18)
I’m trying to make a “http client worker” that recieves requests via chan, and once it has the response, it sends it back to the requester via another chan. Requests contains the chan that the worker should respond on. Is it a good practice? Sending channels on channels?
I’ve done something similar before, but I think I wound up sending promises instead
something like (defn client-req [client params] (let [p (promise)] (>!! (:chan client) {:req params :promise p}) p))
Basically. The semantics of promise
better fit my use case.
why dyu want to do that @nooga ? are you wanting to control the # of concurrent requests with a buffered channel or something ?
you make a rest call somewhere, and it is going to call you back with the answer later
any time I want to get io off of go blocks, usually I have some thread pool where the io is done
so for go blocks to do io they submit tasks to the threadpool and those tasks write their results to a channel when the io is done