Go Development Patterns
Golang Concurrency Patterns : Fan in, Fan out
One of the most prominent reasons of loving Golang personally, is how easy we can build a highly available concurrent and non blocking program.
In this series of posts, I will try to reminisce the patterns available in Golang. I will take every pattern and discuss in detail where they fit and how to use them effectively.
What is Fan in and Fan out. It’s a way to converge and diverge data into a single data stream from multiple streams or from one stream to multiple streams or pipelines.
A generator function
For this pattern to discuss, we need a data source first. Here is a generator of data which can be used as a data source.
The above function as it is evident returns a receive only channel.
The consumer of this function can only receive data from the channel.