Sha256: d6a66408afbf9c34cce4d9b6ba40373fa19b7419cc9132f56ad6ed75fef954cc

Contents?: true

Size: 1.15 KB

Versions: 11

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module Rdkafka
  class Producer
    # Handle to wait for a delivery report which is returned when
    # producing a message.
    class DeliveryHandle < Rdkafka::AbstractHandle
      layout :pending, :bool,
             :response, :int,
             :partition, :int,
             :offset, :int64,
             :topic_name, :pointer

      # @return [String] the name of the operation (e.g. "delivery")
      def operation_name
        "delivery"
      end

      # @return [DeliveryReport] a report on the delivery of the message
      def create_result
        if self[:response] == 0
          DeliveryReport.new(
            self[:partition],
            self[:offset],
            self[:topic_name].read_string
          )
        else
          DeliveryReport.new(
            self[:partition],
            self[:offset],
            # For part of errors, we will not get a topic name reference and in cases like this
            # we should not return it
            self[:topic_name].null? ? nil : self[:topic_name].read_string,
            Rdkafka::RdkafkaError.build(self[:response])
          )
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
karafka-rdkafka-0.13.10 lib/rdkafka/producer/delivery_handle.rb
karafka-rdkafka-0.14.4 lib/rdkafka/producer/delivery_handle.rb
karafka-rdkafka-0.14.3 lib/rdkafka/producer/delivery_handle.rb
karafka-rdkafka-0.14.2 lib/rdkafka/producer/delivery_handle.rb
karafka-rdkafka-0.14.1 lib/rdkafka/producer/delivery_handle.rb
karafka-rdkafka-0.14.0 lib/rdkafka/producer/delivery_handle.rb
karafka-rdkafka-0.14.0.beta1 lib/rdkafka/producer/delivery_handle.rb
karafka-rdkafka-0.13.9 lib/rdkafka/producer/delivery_handle.rb
karafka-rdkafka-0.13.8 lib/rdkafka/producer/delivery_handle.rb
karafka-rdkafka-0.13.7 lib/rdkafka/producer/delivery_handle.rb
karafka-rdkafka-0.13.6 lib/rdkafka/producer/delivery_handle.rb