Class: Kafka::Protocol::ListOffsetRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/kafka/protocol/list_offset_request.rb

Overview

A request to list the available offsets for a set of topics/partitions.

API Specification

OffsetRequest => ReplicaId [TopicName [Partition Time MaxNumberOfOffsets]]
  ReplicaId => int32
  TopicName => string
  Partition => int32
  Time => int64
  MaxNumberOfOffsets => int32

Instance Method Summary collapse

Constructor Details

#initialize(topics:) ⇒ ListOffsetRequest

Returns a new instance of ListOffsetRequest.

Parameters:

  • topics (Hash)

17
18
19
20
# File 'lib/kafka/protocol/list_offset_request.rb', line 17

def initialize(topics:)
  @replica_id = REPLICA_ID
  @topics = topics
end

Instance Method Details

#api_keyObject


22
23
24
# File 'lib/kafka/protocol/list_offset_request.rb', line 22

def api_key
  2
end

#encode(encoder) ⇒ Object


30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/kafka/protocol/list_offset_request.rb', line 30

def encode(encoder)
  encoder.write_int32(@replica_id)

  encoder.write_array(@topics) do |topic, partitions|
    encoder.write_string(topic)

    encoder.write_array(partitions) do |partition|
      encoder.write_int32(partition.fetch(:partition))
      encoder.write_int64(partition.fetch(:time))
      encoder.write_int32(partition.fetch(:max_offsets))
    end
  end
end

#response_classObject


26
27
28
# File 'lib/kafka/protocol/list_offset_request.rb', line 26

def response_class
  Protocol::ListOffsetResponse
end