Module: WaterDrop::Patches::Rdkafka::Producer

Defined in:
lib/waterdrop/patches/rdkafka/producer.rb

Overview

Rdkafka::Producer patches

Instance Method Summary collapse

Instance Method Details

#nameString

Adds a method that allows us to get the native kafka producer name

Returns:

  • (String)

    producer instance name



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/waterdrop/patches/rdkafka/producer.rb', line 12

def name
  unless @_native
    version = ::Gem::Version.new(::Rdkafka::VERSION)
    change = ::Gem::Version.new('0.12.0')
    # 0.12.0 changed how the native producer client reference works.
    # This code supports both older and newer versions of rdkafka
    @_native = version >= change ? @client.native : @native_kafka
  end

  ::Rdkafka::Bindings.rd_kafka_name(@_native)
end