Class: Kafka::Protocol::OffsetCommitRequest

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

Constant Summary collapse

DEFAULT_RETENTION_TIME =

This value signals to the broker that its default configuration should be used.

-1

Instance Method Summary collapse

Constructor Details

#initialize(group_id:, generation_id:, member_id:, retention_time: DEFAULT_RETENTION_TIME, offsets:) ⇒ OffsetCommitRequest

Returns a new instance of OffsetCommitRequest.



21
22
23
24
25
26
27
# File 'lib/kafka/protocol/offset_commit_request.rb', line 21

def initialize(group_id:, generation_id:, member_id:, retention_time: DEFAULT_RETENTION_TIME, offsets:)
  @group_id = group_id
  @generation_id = generation_id
  @member_id = member_id
  @retention_time = retention_time
  @offsets = offsets
end

Instance Method Details

#api_keyObject



9
10
11
# File 'lib/kafka/protocol/offset_commit_request.rb', line 9

def api_key
  OFFSET_COMMIT_API
end

#api_versionObject



13
14
15
# File 'lib/kafka/protocol/offset_commit_request.rb', line 13

def api_version
  2
end

#encode(encoder) ⇒ Object



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

def encode(encoder)
  encoder.write_string(@group_id)
  encoder.write_int32(@generation_id)
  encoder.write_string(@member_id)
  encoder.write_int64(@retention_time)

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

    encoder.write_array(partitions) do |partition, offset|
      encoder.write_int32(partition)
      encoder.write_int64(offset)
      encoder.write_string(nil) # metadata
    end
  end
end

#response_classObject



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

def response_class
  OffsetCommitResponse
end