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

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

Overview

Controller responsible for viewing topics offsets details

Instance Method Summary collapse

Instance Method Details

#show(topic_name) ⇒ Object

Displays high and low offsets for given topic

Parameters:

  • topic_name (String)

    topic we're interested in



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/karafka/web/pro/ui/controllers/topics/offsets_controller.rb', line 49

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

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

  all_offsets = Admin.read_watermark_offsets(topic_name => @active_partitions)

  offsets = @active_partitions.map do |partition_id|
    part_offsets = all_offsets.fetch(topic_name).fetch(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