Class: Kafka::Protocol::AddPartitionsToTxnRequest

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

Instance Method Summary collapse

Constructor Details

#initialize(transactional_id: nil, producer_id:, producer_epoch:, topics:) ⇒ AddPartitionsToTxnRequest

Returns a new instance of AddPartitionsToTxnRequest


6
7
8
9
10
11
# File 'lib/kafka/protocol/add_partitions_to_txn_request.rb', line 6

def initialize(transactional_id: nil, producer_id:, producer_epoch:, topics:)
  @transactional_id = transactional_id
  @producer_id = producer_id
  @producer_epoch = producer_epoch
  @topics = topics
end

Instance Method Details

#api_keyObject


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

def api_key
  ADD_PARTITIONS_TO_TXN_API
end

#encode(encoder) ⇒ Object


21
22
23
24
25
26
27
28
29
30
31
# File 'lib/kafka/protocol/add_partitions_to_txn_request.rb', line 21

def encode(encoder)
  encoder.write_string(@transactional_id.to_s)
  encoder.write_int64(@producer_id)
  encoder.write_int16(@producer_epoch)
  encoder.write_array(@topics.to_a) do |topic, partitions|
    encoder.write_string(topic)
    encoder.write_array(partitions) do |partition|
      encoder.write_int32(partition)
    end
  end
end

#response_classObject


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

def response_class
  AddPartitionsToTxnResponse
end