class Kafka::FetchedBatch
An ordered sequence of messages fetched from a Kafka
partition.
Attributes
highwater_mark_offset[R]
@return [Integer] the offset of the most recent message in the partition.
last_offset[R]
@return [Integer]
leader_epoch[R]
@return [Integer]
messages[RW]
@return [Array<Kafka::FetchedMessage>]
partition[R]
@return [Integer]
topic[R]
@return [String]
Public Class Methods
new(topic:, partition:, highwater_mark_offset:, messages:, last_offset: nil, leader_epoch: nil)
click to toggle source
# File lib/kafka/fetched_batch.rb, line 25 def initialize(topic:, partition:, highwater_mark_offset:, messages:, last_offset: nil, leader_epoch: nil) @topic = topic @partition = partition @highwater_mark_offset = highwater_mark_offset @messages = messages @last_offset = last_offset @leader_epoch = leader_epoch end
Public Instance Methods
empty?()
click to toggle source
# File lib/kafka/fetched_batch.rb, line 34 def empty? @messages.empty? end
first_offset()
click to toggle source
# File lib/kafka/fetched_batch.rb, line 42 def first_offset if empty? nil else messages.first.offset end end
offset_lag()
click to toggle source
# File lib/kafka/fetched_batch.rb, line 50 def offset_lag if empty? 0 else (highwater_mark_offset - 1) - last_offset end end
unknown_last_offset?()
click to toggle source
# File lib/kafka/fetched_batch.rb, line 38 def unknown_last_offset? @last_offset.nil? end