Skip to content

Instantly share code, notes, and snippets.

@chris001177
Last active July 28, 2019 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris001177/3fb66049ecca0bb7e434496996648dc2 to your computer and use it in GitHub Desktop.
Save chris001177/3fb66049ecca0bb7e434496996648dc2 to your computer and use it in GitHub Desktop.
package main
import (
"log"
sarama "gopkg.in/Shopify/sarama.v1"
)
// Process response grabs results and errors from a producer
// asynchronously
func ProcessResponse(producer sarama.AsyncProducer) {
for {
select {
case result := <-producer.Successes():
log.Printf("> message: \"%s\" sent to partition %d at offset %d\n", result.Value, result.Partition, result.Offset)
case err := <-producer.Errors():
log.Println("Failed to produce message", err)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment