I need your help. Currently i'm trying to create a worker pool that reads continuous jobs from a channel and then produces the result to the same channel it is reading from to then do work and produce the result to the same channel. you get the idea sorta like recursion. Is there any way to make this possible? I would really your appreciate advice on design patterns to implement this solution using go routines as a worker pool and channels to read in jobs and then from the same worker pool write the result of that job to the same channel to keep working. Thank you.
There is no reason why something can't (from Go's perspective) write back to a channel after reading it:
func Foo(c chan int) {
x := <-c
// do something to x
c <- x
}
This is weird though... And honestly would not recommend it. Normally I have seen a system composed of several channels with data being passed down and not entering cycles. Think trees instead of graphs.