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

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

#topicString

We use this instead of reading from topic_name pointer to save on memory allocations

Returns:

  • (String)

    topic where we are trying to send the message



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

def topic
  @topic
end

Instance Method Details

#create_resultDeliveryReport

Returns a report on the delivery of the message.

Returns:



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

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



22
23
24
# File 'lib/rdkafka/producer/delivery_handle.rb', line 22

def operation_name
  "delivery"
end