Fork me on GitHub
#pedestal
<
2019-07-15
>
stacktracer20:07:46

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)))))

ddeaguiar21:07:36

@stacktracer I can’t think of a reason in this case. There are no options being passed during channel creation in this example.

stacktracer23:07:59

@ddeaguiar Thanks for the sanity check!