Class: Karafka::Web::Ui::Models::WatermarkOffsets

Inherits:
Lib::HashProxy show all
Defined in:
lib/karafka/web/ui/models/watermark_offsets.rb

Overview

Model used for accessing watermark offsets

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Lib::HashProxy

#initialize, #method_missing, #respond_to_missing?, #to_h

Constructor Details

This class inherits a constructor from Karafka::Web::Ui::Lib::HashProxy

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Karafka::Web::Ui::Lib::HashProxy

Class Method Details

.find(topic_id, partition_id) ⇒ WatermarkOffsets

Retrieve watermark offsets for given topic partition

Parameters:

  • topic_id (String)
  • partition_id (Integer)

Returns:



15
16
17
18
19
20
21
22
# File 'lib/karafka/web/ui/models/watermark_offsets.rb', line 15

def find(topic_id, partition_id)
  offsets = Lib::Admin.read_watermark_offsets(topic_id, partition_id)

  new(
    low: offsets.first,
    high: offsets.last
  )
end

Instance Method Details

#cleaned?Boolean

Returns true if given partition had data but all of it was removed due to log retention and compaction policies.

Returns:

  • (Boolean)

    true if given partition had data but all of it was removed due to log retention and compaction policies



32
33
34
# File 'lib/karafka/web/ui/models/watermark_offsets.rb', line 32

def cleaned?
  !empty? && low == high
end

#empty?Boolean

Returns true if given partition never had any messages and is empty.

Returns:

  • (Boolean)

    true if given partition never had any messages and is empty



26
27
28
# File 'lib/karafka/web/ui/models/watermark_offsets.rb', line 26

def empty?
  low.zero? && high.zero?
end