Is there an easy way to limit the write frequency to a core.async channel ? So far I could find two examples. One uses a sliding-buffer and some SetTimeout magic to handle this the other uses an external atom as a counter. I would have expected that core.async provides such functionality out of the box. Since one of the examples is rather old (10 month) I would like to know if theres is maybe an easier solution ?
I'm looking for a solution that works with Clojure and ClojureScript.
The throttler lib provides functions to impose rate controls on Clojure code (including throttles on channels or functions).
From the readme:
(def in (chan 1))
(def slow-chan (throttle-chan in 1 :millisecond)) ; 1 msg/ms
(>!! in :token) ; => true
(<!! slow-chan) ; :token
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With