Class: Karafka::Web::Pro::Ui::Controllers::Consumers::ConsumersController

Inherits:
BaseController
  • Object
show all
Includes:
Ui::Lib::Paginations
Defined in:
lib/karafka/web/pro/ui/controllers/consumers/consumers_controller.rb

Overview

Controller for displaying consumers states and details about them

Instance Method Summary collapse

Instance Method Details

#details(process_id) ⇒ Object

Parameters:

  • process_id (String)

    id of the process we're interested in



102
103
104
105
106
107
# File 'lib/karafka/web/pro/ui/controllers/consumers/consumers_controller.rb', line 102

def details(process_id)
  current_state = Models::ConsumersState.current!
  @process = Models::Process.find(current_state, process_id)

  render
end

#indexObject

Consumers list



80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/karafka/web/pro/ui/controllers/consumers/consumers_controller.rb', line 80

def index
  @current_state = Models::ConsumersState.current!
  @counters = Models::Counters.new(@current_state)

  @processes, last_page = Paginators::Arrays.call(
    filter(sort(Models::Processes.active(@current_state))),
    @params.current_page
  )

  paginate(@params.current_page, !last_page)

  render
end

#performanceObject

Displays per-process performance details



95
96
97
98
99
# File 'lib/karafka/web/pro/ui/controllers/consumers/consumers_controller.rb', line 95

def performance
  index

  render
end

#subscriptions(process_id) ⇒ Object

Parameters:

  • process_id (String)

    id of the process we're interested in



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/karafka/web/pro/ui/controllers/consumers/consumers_controller.rb', line 110

def subscriptions(process_id)
  details(process_id)

  # We want to have sorting but on a per subscription group basis and not to sort
  # everything
  @process.consumer_groups.each do |consumer_group|
    # We need to initialize the whole structure so dynamic fields are also built into
    # the underlying hashes for sorting
    consumer_group.subscription_groups.flat_map(&:topics).flat_map(&:partitions)

    sort(consumer_group)
  end

  render
end