This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-15
Channels
- # aleph (9)
- # announcements (6)
- # beginners (42)
- # calva (4)
- # cider (9)
- # clara (2)
- # clj-kondo (1)
- # cljdoc (108)
- # cljs-dev (10)
- # clojure (25)
- # clojure-brasil (1)
- # clojure-chicago (1)
- # clojure-europe (4)
- # clojure-italy (42)
- # clojure-nl (14)
- # clojure-uk (66)
- # clojurebridge (3)
- # clojurescript (23)
- # clojutre (2)
- # community-development (1)
- # cursive (2)
- # datomic (4)
- # figwheel-main (21)
- # fulcro (23)
- # jobs-discuss (1)
- # kaocha (1)
- # off-topic (10)
- # pedestal (4)
- # reitit (2)
- # shadow-cljs (41)
- # spacemacs (7)
- # sql (20)
- # xtdb (3)
Noob question ... in the pedestal async example:
(interceptors/defbefore takes-time
[context]
(let [channel (chan)]
(go
(let [result (lengthy-computation (:request context))
new-context (assoc context :response (ring-resp/response result))]
(>! channel new-context)))
channel))
... is there a reason to create channel
explicitly, rather than use the implicit channel that receives the result of the go
body?
In other words, why do the above instead of this:
(interceptors/defbefore takes-time
[context]
(go
(let [result (lengthy-computation (:request context))]
(assoc context :response (ring-resp/response result)))))
The example in question is here: https://github.com/pedestal/pedestal/blob/master/guides/documentation/service-async.md#asynchronous-processing
@stacktracer I can’t think of a reason in this case. There are no options being passed during channel creation in this example.
@ddeaguiar Thanks for the sanity check!