a channel every x seconds. Now I need a worker pool which is waiting for new data (infinitely) and working on them. I tried multiple ways but I can figure out how to do it for an infinite amount of jobs...
Currently it's working like that with one worker:
for {
data := <-testChannel
compute(data)
}
So I am stupidly waiting for new data and work with it. I would like to call compute as goroutine, but then I would have an infinite amount of them because I don't control the amount. I tried it with work groups and an int channel with the max amount fo goroutines, both didn't work. What would you do to solve that? I will always have more data available, so the channel won't be empty.
You want to control the number of compute goroutines?
Обсуждают сегодня