Consumer Producer implementation with golang
07 Oct 2013
Today I invested my whole day in evaluating GoLang for one of our component implementations. Since the first document, I got impressed by it’’’s construct. Till I reached the ultimate problem solution for our case, I fell in love with this new language. It gives you the power of OS level constructs keeping a lot of overheads hidden from you. I was playing with a lot of simple problems while reading the documentation and here I am sharing one of those implementation and will discuss how simple it is to implement pretty complex problems with GoLang.
Classic Consumer-Producer problem
You can find some classic implemetations here.
GoLang implementation:
Components
Channels
Channels are the basic inter go-routine communication model. If you are a Java developer you can consider it as array blocking queue, which is mostly used for inter-thread communication.
Go routine
Go routines are the lightweight Thread implementation for Go.
You can learn Go with some amazing examples here. Initial impressions of Go are pretty good. Will share more info as we discover it during our implementations.