Sha256: 2429d56bc202d26eef295f2362a99274a80ff47ac5e61637346103388416643e

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 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,
            RdkafkaError.new(self[:response])
          )
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
karafka-rdkafka-0.13.5 lib/rdkafka/producer/delivery_handle.rb