Is there any way to throtle the messages to a chan...
# coroutines
r
Is there any way to throtle the messages to a channel? Adding delay to the messages given a param of the msg. Linke a priority queue or delayed queue? I though to just run a coroutine and then delay but it seems no good for a fan out scenario.
z
Do you want to throttle the messages being sent to the channel, or being sent to consumers of the channel? If the latter, it sounds like you should be using Flow instead of exposing a channel directly.
r
Actually to a work pool. I'd like to add a delay for a htp calls to same host, but keeping calling for other as much as available.
@Zach Klippenstein (he/him) [MOD] Would you have exmples of it?
z
Could you keep a map of host to semaphore, and use the semaphores to throttle per-host?
r
The apache client does it to ative max per host. But no add a delay after a call no. I was wordering to do it without a semaphore. In java you have thr DelayedQuee or Priority. The most close thing I found in kotlin was a time schedule.
z
Just call
delay()
from your worker coroutines?