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!