Class: Karafka::Web::Pro::Ui::Controllers::RoutingController

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

Overview

Routing details - same as in OSS

Constant Summary

Constants inherited from Ui::Controllers::BaseController

Ui::Controllers::BaseController::Models

Instance Method Summary collapse

Methods inherited from Ui::Controllers::BaseController

#initialize

Constructor Details

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

Instance Method Details

#indexObject

Routing list



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/karafka/web/pro/ui/controllers/routing_controller.rb', line 27

def index
  detect_patterns_routes

  @routes = Karafka::App.routes
  @routes.each do |consumer_group|
    refine(consumer_group.topics)
  end

  current_state = Models::ConsumersState.current
  @assigned = Hash.new { |h, k| h[k] = Set.new }

  # If there are active processes, we can use their data to mark certain topics as
  # assigned. This does not cover the full scope as some partitions may be assigned
  # and some not, but provides general overview
  if current_state
    Models::Processes.active(current_state).each do |process|
      process.consumer_groups.each do |consumer_group|
        consumer_group.subscription_groups.each do |subscription_group|
          subscription_group.topics.each do |topic|
            @assigned[consumer_group.id.to_s] << topic.name
          end
        end
      end
    end
  end

  render
end

#show(topic_id) ⇒ Object

Given route details

Parameters:

  • topic_id (String)

    topic id



59
60
61
62
63
64
65
66
67
# File 'lib/karafka/web/pro/ui/controllers/routing_controller.rb', line 59

def show(topic_id)
  detect_patterns_routes

  @topic = Karafka::Routing::Router.find_by(id: topic_id)

  @topic || not_found!(topic_id)

  render
end