Sha256: 5f04211ddae111fb10feb24ec8eed9afad8eefdbf627c2f1de668b9d4f5f817f

Contents?: true

Size: 889 Bytes

Versions: 6

Compression:

Stored size: 889 Bytes

Contents

# frozen_string_literal: true

module WaterDrop
  # Patches to external components
  module Patches
    # Rdkafka related patches
    module Rdkafka
      # Rdkafka::Producer patches
      module Producer
        # Adds a method that allows us to get the native kafka producer name
        # @return [String] producer instance name
        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
      end
    end
  end
end

::Rdkafka::Producer.include ::WaterDrop::Patches::Rdkafka::Producer

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
waterdrop-2.4.2 lib/waterdrop/patches/rdkafka/producer.rb
waterdrop-2.4.1 lib/waterdrop/patches/rdkafka/producer.rb
waterdrop-2.4.0 lib/waterdrop/patches/rdkafka/producer.rb
waterdrop-2.3.3 lib/waterdrop/patches/rdkafka/producer.rb
waterdrop-2.3.2 lib/waterdrop/patches/rdkafka/producer.rb
waterdrop-2.3.1 lib/waterdrop/patches/rdkafka/producer.rb