aleph

2017-07-12T16:05:33.358366Z

If I have a Deferred what is the recommended way to "convert" it to core.async channel?

dm3 2017-07-12T16:16:48.759260Z

(go @deferred)? But be aware if the deferred is blocked on IO

2017-07-12T16:22:32.960472Z

Aah, of course. How would that work in case of Manifold stream?

dm3 2017-07-12T16:27:07.119960Z

(let [chan (async/chan)]
  (m.s/consume #(async/put! chan %) stream))

2017-07-12T16:52:18.983005Z

That solves the incoming part. What about outgoing? I have a duplex stream

dm3 2017-07-12T16:54:20.052872Z

You can simply convert via (m.s/->source chan)

dm3 2017-07-12T16:55:16.084433Z

be aware that with async/put! method above there’s no backpressure so the chan might be overwhelmed (depending on the buffer used)

dm3 2017-07-12T16:56:32.129282Z

you’d probably want to use stream/consume-async and put! with more options to respect backpressure/closing of chan

2017-07-12T17:11:59.658715Z

Thanks. My case is following. I am going to use Aleph for tcp server and client. However, I would like to work with core.async channels instead of Manifold streams.