Class: Karafka::Web::Pro::Ui::Controllers::Topics::OffsetsController

Inherits:
BaseController show all
Defined in:
lib/karafka/web/pro/ui/controllers/topics/offsets_controller.rb

Overview

Controller responsible for viewing topics offsets details

Constant Summary

Constants inherited from Ui::Controllers::BaseController

Ui::Controllers::BaseController::Models

Instance Attribute Summary

Attributes inherited from Ui::Controllers::BaseController

#params, #session

Instance Method Summary collapse

Methods inherited from Ui::Controllers::BaseController

#cache, #initialize

Methods included from Ui::Controllers::Requests::Hookable

included, #run_after_hooks, #run_before_hooks

Constructor Details

This class inherits a constructor from Karafka::Web::Ui::Controllers::BaseController

Instance Method Details

#show(topic_name) ⇒ Object

Displays high and low offsets for given topic

Parameters:

  • topic_name (String)

    topic we’re interested in



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/karafka/web/pro/ui/controllers/topics/offsets_controller.rb', line 24

def show(topic_name)
  @topic = Models::Topic.find(topic_name)

  @active_partitions, _materialized_page, @limited = Paginators::Partitions.call(
    @topic.partition_count, @params.current_page
  )

  offsets = @active_partitions.map do |partition_id|
    part_offsets = Admin.read_watermark_offsets(topic_name, partition_id)

    {
      partition_id: partition_id,
      low: part_offsets.first,
      high: part_offsets.last,
      diff: part_offsets.last - part_offsets.first
    }
  end

  @offsets = refine(offsets)

  next_page = @active_partitions.last < @topic.partition_count - 1
  paginate(@params.current_page, next_page)

  render
end