Class: Rdkafka::Callbacks::CreatePartitionsHandler

Inherits:
BaseHandler
  • Object
show all
Defined in:
lib/rdkafka/callbacks/create_partitions_handler.rb

Overview

Handles RD_KAFKA_ADMIN_OP_CREATEPARTITIONS_RESULT events

Class Method Summary collapse

Class Method Details

.call(event_ptr) ⇒ void

This method returns an undefined value.

Resolves the create-partitions handle from its result event

Parameters:

  • event_ptr (FFI::Pointer)

    pointer to the event



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rdkafka/callbacks/create_partitions_handler.rb', line 12

def call(event_ptr)
  create_partitionss_result = Rdkafka::Bindings.rd_kafka_event_CreatePartitions_result(event_ptr)

  # Get the number of create topic results
  pointer_to_size_t = FFI::MemoryPointer.new(:size_t)
  create_partitions_result_array = Rdkafka::Bindings.rd_kafka_CreatePartitions_result_topics(create_partitionss_result, pointer_to_size_t)
  create_partitions_results = TopicResult.create_topic_results_from_array(pointer_to_size_t.read_int, create_partitions_result_array)
  create_partitions_handle_ptr = Rdkafka::Bindings.rd_kafka_event_opaque(event_ptr)

  if create_partitions_handle = Rdkafka::Admin::CreatePartitionsHandle.remove(create_partitions_handle_ptr.address)
    unless resolve_operation_error(event_ptr, create_partitions_handle)
      create_partitions_handle[:response] = create_partitions_results[0].result_error
      create_partitions_handle.result = Rdkafka::Admin::CreatePartitionsReport.new(
        create_partitions_results[0].error_string,
        create_partitions_results[0].result_name
      )
      create_partitions_handle.broker_message = create_partitions_handle.result.error_string

      create_partitions_handle.unlock
    end
  end
end