core-async

fabrao 2020-05-26T03:01:36.321800Z

hello all

fabrao 2020-05-26T03:02:03.322400Z

Is there any way to stop the processing of this block?

(let [saida (chan)
	  lojas ["STORE-01" "STORE-02" "STORE-03" "STORE-04"]]
    (pipeline-blocking 10
                       saida
                       (map #(do
                               (logger/debug (str "Loja -> " (:servidor %)))
                               (ls/executar-query-linkedserver db (:servidor %) (slurp "sql/semanal/tempo-backup.sql"))))
                       (to-chan lojas))
    (<!! (a/into [] saida)))

fabrao 2020-05-26T03:03:12.323300Z

when I have so many "STORE"s, I canĀ“t stop the execution until the end of pipeline-blocking

fabrao 2020-05-26T03:03:35.323600Z

is there any way to stop the execution?

2020-05-26T14:51:39.326100Z

@fabrao do you know how many items in lojas is too many? if so, I would change the implementation of to-chan to a go-loop with a counter and perform close! on lojas when the counter reaches your limit

2020-05-26T16:43:43.326600Z

or even just a take n transducer on the channel

fabrao 2020-05-26T16:44:30.327100Z

@danboykis lojas will be around 100

2020-05-26T17:57:09.328500Z

@fabrao how would you know it's too many? If there's a specific maximum count, you can add a (take N) transducer, if there's a condition you can check via a function call, you can use a take-while transducer that runs your test