Skip to content

Commit

Permalink
Avoid deprecation warning for produce.offset.report with newer librdk…
Browse files Browse the repository at this point in the history
…afka versions
  • Loading branch information
edenhill committed Oct 24, 2018
1 parent 4f17205 commit 460e8e4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions kafka/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

2 comments on commit 460e8e4

@agis
Copy link
Contributor

@agis agis commented on 460e8e4 Nov 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edenhill Is rd_kafka_version() computed at build-time or run-time? I'm noticing this deprecation warning even though I'm using confluent-kafka-go 0.11.6 and librdkafka 1.2.0 (with LD_PRELOAD), and I don't set produce.offset.report.

@edenhill
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rd_kafka_version() is the runtime, not build (RD_KAFKA_VERSION), version.

Please sign in to comment.