Class: Rdkafka::Admin::ListOffsetsReport

Inherits:
Object
  • Object
show all
Defined in:
lib/rdkafka/admin/list_offsets_report.rb

Overview

Report for list offsets operation result

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result_infos:, result_count:) ⇒ ListOffsetsReport

Returns a new instance of ListOffsetsReport.

Parameters:

  • result_infos (FFI::Pointer)

    pointer to result info array

  • result_count (Integer)

    number of result info entries



11
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/admin/list_offsets_report.rb', line 11

def initialize(result_infos:, result_count:)
  @offsets = []

  return if result_infos.null?

  result_infos
    .read_array_of_pointer(result_count)
    .each { |result_info_ptr| validate!(result_info_ptr) }
    .each do |result_info_ptr|
      tp_ptr = Bindings.rd_kafka_ListOffsetsResultInfo_topic_partition(result_info_ptr)
      tp = Bindings::TopicPartition.new(tp_ptr)
      timestamp = Bindings.rd_kafka_ListOffsetsResultInfo_timestamp(result_info_ptr)
      leader_epoch = Bindings.rd_kafka_topic_partition_get_leader_epoch(tp_ptr)

      @offsets << {
        topic: tp[:topic],
        partition: tp[:partition],
        offset: tp[:offset],
        timestamp: timestamp,
        leader_epoch: (leader_epoch == -1) ? nil : leader_epoch
      }
    end
end

Instance Attribute Details

#offsetsObject (readonly)

Returns the value of attribute offsets.



7
8
9
# File 'lib/rdkafka/admin/list_offsets_report.rb', line 7

def offsets
  @offsets
end