From 460e8e43b282a1a68219df600ef63442b81faf5f Mon Sep 17 00:00:00 2001 From: Magnus Edenhill Date: Wed, 24 Oct 2018 09:58:22 +0200 Subject: [PATCH] Avoid deprecation warning for produce.offset.report with newer librdkafka versions --- kafka/producer.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kafka/producer.go b/kafka/producer.go index f2cbc9656..7eac91261 100644 --- a/kafka/producer.go +++ b/kafka/producer.go @@ -414,10 +414,13 @@ func NewProducer(conf *ConfigMap) (*Producer, error) { } produceChannelSize := v.(int) - v, _ = confCopy.extract("{topic}.produce.offset.report", nil) - if v == nil { - // Enable offset reporting by default, unless overriden. - confCopy.SetKey("{topic}.produce.offset.report", true) + if int(C.rd_kafka_version()) < 0x01000000 { + // produce.offset.report is no longer used in librdkafka >= v1.0.0 + v, _ = confCopy.extract("{topic}.produce.offset.report", nil) + if v == nil { + // Enable offset reporting by default, unless overriden. + confCopy.SetKey("{topic}.produce.offset.report", true) + } } // Convert ConfigMap to librdkafka conf_t