diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2024-02-07 14:02:22 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2024-02-07 14:02:22 +0100 |
commit | acf44b68569f6615d373f05f92671afecb296af8 (patch) | |
tree | 337b49bb93ed8cc08096e803065c72f3e87f9642 /producer.go | |
parent | c4d37d593262f8ff0053693513d1a5e397ff2b5d (diff) | |
download | kafka-sandbox-acf44b68569f6615d373f05f92671afecb296af8.tar.gz kafka-sandbox-acf44b68569f6615d373f05f92671afecb296af8.tar.bz2 kafka-sandbox-acf44b68569f6615d373f05f92671afecb296af8.tar.xz kafka-sandbox-acf44b68569f6615d373f05f92671afecb296af8.zip |
wip
Diffstat (limited to 'producer.go')
-rw-r--r-- | producer.go | 9 |
1 files changed, 6 insertions, 3 deletions
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 |