Fork me on GitHub
#core-async
<
2017-05-13
>
kwladyka22:05:35

i am trying to do queue with async, but it confuse me. I have queue and i want get from this queue max 20 items on each iteration (when 10 items i want get 10 items and do job, not wait for 20). How to do it in most simple way? After each iteration i want do X seconds of break.

serioga16:05:18

kwladyka: looks like you need two channels, one for data and another for iteration control. so when you get input from control channel then you process up to 20 items from data channel and so on.

serioga16:05:52

also it's possible that for you task the algorithm is not a best but from your description is not clear why algorithm is like you described.

kwladyka16:05:41

it is because i can’t flood server with requests, server get max 20 items at once in request

serioga17:05:13

@U0WL6FA77 so you can use async/pipeline functions for guaranteed processing of limited amount of items simultaneously https://clojuredocs.org/clojure.core.async/pipeline-blocking

serioga17:05:21

another option is to use http library with connection pooling

kwladyka17:05:04

i will check this pipeline-blocking today, thx for hint

kwladyka19:05:01

thx, interesting library

kwladyka21:05:34

Do you have example of use pipeline-blocking? I was trying to find something in google but didn’t find.

kwladyka22:05:53

hmm or maybe async is not right choice

serioga16:05:18

kwladyka: looks like you need two channels, one for data and another for iteration control. so when you get input from control channel then you process up to 20 items from data channel and so on.