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]

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) click to toggle source
# File lib/kafka/fetched_batch.rb, line 22
def initialize(topic:, partition:, highwater_mark_offset:, messages:, last_offset: nil)
  @topic = topic
  @partition = partition
  @highwater_mark_offset = highwater_mark_offset
  @messages = messages
  @last_offset = last_offset
end

Public Instance Methods

empty?() click to toggle source
# File lib/kafka/fetched_batch.rb, line 30
def empty?
  @messages.empty?
end
first_offset() click to toggle source
# File lib/kafka/fetched_batch.rb, line 38
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 46
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 34
def unknown_last_offset?
  @last_offset.nil?
end