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
  IsolationLevel => int8
  TopicName => string
  Partition => int32
  Time => int64

Constant Summary collapse

ISOLATION_READ_UNCOMMITTED =
0
ISOLATION_READ_COMMITTED =
1

Instance Method Summary collapse

Constructor Details

#initialize(topics:) ⇒ ListOffsetRequest

Returns a new instance of ListOffsetRequest.

Parameters:

  • topics (Hash)


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

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

Instance Method Details

#api_keyObject



30
31
32
# File 'lib/kafka/protocol/list_offset_request.rb', line 30

def api_key
  LIST_OFFSET_API
end

#api_versionObject



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

def api_version
  2
end

#encode(encoder) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/kafka/protocol/list_offset_request.rb', line 38

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

  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))
    end
  end
end

#response_classObject



34
35
36
# File 'lib/kafka/protocol/list_offset_request.rb', line 34

def response_class
  Protocol::ListOffsetResponse
end