Fork me on GitHub
#core-async
<
2017-06-05
>
plins18:06:26

hello everyone, i know JDBC is synchonous and theres nothing to do about it but id like a channel API on top of it.. considering im using JDBC + c3p0, which has its own threadpool, and id like to receive a channel when doing jdbc/query ["select * from t"]), should i use async.core/go or async.core/thread ?

ghadi18:06:38

go is for non-blocking stuff

noisesmith19:06:41

re-sharing this since it’s a weekday- an experimental variation on core.async/thread that attempts to cancel the thread if you close the channel https://gist.github.com/noisesmith/02ee2ee5dcb8c0290bd8004c4c4d36aa

kkruit19:06:36

I'm trying to create a pipeline but ever time i put into the channel the last item in the pipeline is being removed. I'm having trouble wrapping my head around where I'm going wrong.

kkruit19:06:48

This is how I'm using it:

noisesmith19:06:44

it’s funny that you call this a pipeline, because there’s a built in function called pipeline that does this

kkruit19:06:11

i'll try that

noisesmith19:06:28

you would add your additional logic as a (map f) transducer on the out channel

kkruit20:06:23

So it looks like pipeline is taking the place of the go while loop but i'm still not doing something right. My idea is that i can thread a channel through multiple pipelined transducers and then every thing i put on the channel has each transducer applied to it. In practice it seems like each time it's called i loose the last transducer.

hiredman20:06:36

what does dbg return?

kkruit20:06:32

that should be (>!! all-in "asdf") if i call that multiple times each time i lose one of the channel-loggers

hiredman20:06:49

my guess is you are getting an exception killing your loops, the default behavior for exceptions in go blocks is to print them out to stderr (or maybe stdout)

hiredman20:06:08

(which isn't always the same thing as the repl)

hiredman20:06:53

actually, no

hiredman20:06:04

I bet you aren't consuming from the output side

hiredman20:06:54

and each loop introduces effectively a buffer of "one", so the Nth time you run in, the Nth from the last transformers "buffer" becomes full, so no more values flow through it

kkruit20:06:04

well i'm seeing that i need to for pipeline but didn't with the go loop

hiredman20:06:36

looking your implementation of chan-chain, you did

kkruit21:06:34

That seemed to work. Thanks a ton!

peeja22:06:50

I'd like to call a function with every value put onto a given channel until the channel closes. Right now I'm doing:

(go-loop []
  (when-let [value (<! ch)]
    (f value)
    (recur)))

peeja22:06:10

Is there an easier way to do that that I'm missing? It seems like a common thing to do.

peeja23:06:47

@hiredman Huh, I hadn't thought of that. Is it okay if I want f for its side-effects and I ignore the return value of reduce?

hiredman23:06:30

I think the only possible issue is it runs the loop in a go block, so f doing any kind of blocking isn't a good idea