Class: Kafka::FetchedBatchGenerator

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

Constant Summary collapse

COMMITTED_TRANSACTION_SIGNAL =
"\x00\x00\x00\x01".freeze
ABORTED_TRANSACTION_SIGNAL =
"\x00\x00\x00\x00".freeze

Instance Method Summary collapse

Constructor Details

#initialize(topic, fetched_partition, offset, logger:) ⇒ FetchedBatchGenerator

Returns a new instance of FetchedBatchGenerator.



10
11
12
13
14
15
# File 'lib/kafka/fetched_batch_generator.rb', line 10

def initialize(topic, fetched_partition, offset, logger:)
  @topic = topic
  @fetched_partition = fetched_partition
  @logger = TaggedLogger.new(logger)
  @offset = offset
end

Instance Method Details

#generateObject



17
18
19
20
21
22
23
24
25
# File 'lib/kafka/fetched_batch_generator.rb', line 17

def generate
  if @fetched_partition.messages.empty?
    empty_fetched_batch
  elsif @fetched_partition.messages.first.is_a?(Kafka::Protocol::MessageSet)
    extract_messages
  else
    extract_records
  end
end