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 Attribute Summary

Attributes inherited from Ui::Controllers::BaseController

#params, #session

Instance Method Summary collapse

Methods included from Lib::Filtering

included, key

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

#indexObject

Routing list



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/karafka/web/pro/ui/controllers/routing_controller.rb', line 52

def index
  detect_patterns_routes

  @routes = Karafka::App.routes
  @routes.each do |consumer_group|
    sort(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



84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/karafka/web/pro/ui/controllers/routing_controller.rb', line 84

def show(topic_id)
  detect_patterns_routes

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

  @topic || not_found!(topic_id)

  # Present the routing settings as a flat, sortable + filterable list of name/value rows
  @details = sort(filter(topic_detail_rows(@topic)))

  render
end