Last active
July 28, 2019 09:23
-
-
Save chris001177/3fb66049ecca0bb7e434496996648dc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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