From acf44b68569f6615d373f05f92671afecb296af8 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 7 Feb 2024 14:02:22 +0100 Subject: wip --- producer.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'producer.go') diff --git a/producer.go b/producer.go index 8cf1b0e..f5392ae 100644 --- a/producer.go +++ b/producer.go @@ -2,11 +2,11 @@ package main import ( "fmt" + "github.com/confluentinc/confluent-kafka-go/v2/kafka" "kafka-sandbox/util" + "log" "math/rand" "os" - - "github.com/confluentinc/confluent-kafka-go/kafka" ) func main() { @@ -49,11 +49,14 @@ func main() { for n := 0; n < 10; n++ { key := users[rand.Intn(len(users))] data := items[rand.Intn(len(items))] - p.Produce(&kafka.Message{ + err := p.Produce(&kafka.Message{ TopicPartition: kafka.TopicPartition{Topic: &topic, Partition: kafka.PartitionAny}, Key: []byte(key), Value: []byte(data), }, nil) + if err != nil { + log.Fatalln(err) + } } // Wait for all messages to be delivered -- cgit v1.2.3