Shopify/sarama — pull request #212 by eapache (2014-11-26 20:35:51+00:00)
Title: Permit real concurrent calls to the SimpleProducer

Without using a mutex.

Turned out to be simpler than I thought.

@ORBAT this should let you use a `SimpleProducer` in your `io.Writer` implementation and get rid of the ugly hash table etc.

@wvanbergen for review

The design is fairly simple: the `matchResponses` goroutine keeps a map of messages sent to expectations, and fulfills the expectations as the messages come back from the underlying producer. `SendMessage` just pushes an expectation before it does the real send.