Class: Kafka::Protocol::TxnOffsetCommitRequest

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

Instance Method Summary collapse

Constructor Details

#initialize(transactional_id:, group_id:, producer_id:, producer_epoch:, offsets:) ⇒ TxnOffsetCommitRequest

Returns a new instance of TxnOffsetCommitRequest


19
20
21
22
23
24
25
# File 'lib/kafka/protocol/txn_offset_commit_request.rb', line 19

def initialize(transactional_id:, group_id:, producer_id:, producer_epoch:, offsets:)
  @transactional_id = transactional_id
  @producer_id = producer_id
  @producer_epoch = producer_epoch
  @group_id = group_id
  @offsets = offsets
end

Instance Method Details

#api_keyObject


7
8
9
# File 'lib/kafka/protocol/txn_offset_commit_request.rb', line 7

def api_key
  TXN_OFFSET_COMMIT_API
end

#api_versionObject


11
12
13
# File 'lib/kafka/protocol/txn_offset_commit_request.rb', line 11

def api_version
  2
end

#encode(encoder) ⇒ Object


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

def encode(encoder)
  encoder.write_string(@transactional_id.to_s)
  encoder.write_string(@group_id)
  encoder.write_int64(@producer_id)
  encoder.write_int16(@producer_epoch)

  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[:offset])
      encoder.write_string(nil) # metadata
      encoder.write_int32(offset[:leader_epoch])
    end
  end
end

#response_classObject


15
16
17
# File 'lib/kafka/protocol/txn_offset_commit_request.rb', line 15

def response_class
  TxnOffsetCommitResponse
end