I have a go application which consists of a ticker which takes from a channel and passes it into another channel, which then is consumed within a worker pool, the result of which gets passed into another channel used in another worker pool.
jobs := make(chan string, 1)
jobs2 := make(chan string, 1)
jobs3 := make(chan string, 100000000)
// How do I free up this worker.
for w := 1; w <= 5; w++ {
go o.workerOne(w, jobs, payloads)
}
for w := 1; w <= 100; w++ {
go o.workerTwo(w, payloads, results)
}
for w := 1; w <= 1000; w++ {
go o.workerThree(w, results)
}
go func() {
for {
select {
case <-o.Context.Done():
return
case _ = <-ticker.C:
jobs <- <-o.Queue
}
}
}
<-sleep.Done()
ticker.Stop()
However once jobs has been passed 5 items then no more work is done, the queue is just constantly appended to, how can I free the workers?