Class: Rdkafka::Producer::DeliveryHandle

Inherits:
AbstractHandle show all
Defined in:
lib/rdkafka/producer/delivery_handle.rb

Overview

Handle to wait for a delivery report which is returned when producing a message.

Constant Summary

Constants inherited from AbstractHandle

AbstractHandle::REGISTRY, AbstractHandle::WAIT_TIMEOUT_DEPRECATION_MESSAGE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractHandle

#initialize, #pending?, #raise_error, register, remove, #unlock, #wait

Methods included from Helpers::Time

#monotonic_now

Constructor Details

This class inherits a constructor from Rdkafka::AbstractHandle

Instance Attribute Details

#labelObject?

Returns label set during message production or nil by default.

Returns:

  • (Object, nil)

    label set during message production or nil by default



15
16
17
# File 'lib/rdkafka/producer/delivery_handle.rb', line 15

def label
  @label
end

Instance Method Details

#create_resultDeliveryReport

Returns a report on the delivery of the message.

Returns:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rdkafka/producer/delivery_handle.rb', line 23

def create_result
  if self[:response] == 0
    DeliveryReport.new(
      self[:partition],
      self[:offset],
      self[:topic_name].read_string,
      nil,
      label
    )
  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]),
      label
    )
  end
end

#operation_nameString

Returns the name of the operation (e.g. "delivery").

Returns:

  • (String)

    the name of the operation (e.g. "delivery")



18
19
20
# File 'lib/rdkafka/producer/delivery_handle.rb', line 18

def operation_name
  "delivery"
end