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

Inherits:
BaseController 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

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

#details(process_id) ⇒ Object

Parameters:

  • process_id (String)

    id of the process we’re interested in



70
71
72
73
74
75
# File 'lib/karafka/web/pro/ui/controllers/consumers/consumers_controller.rb', line 70

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

  render
end

#indexObject

Consumers list



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/karafka/web/pro/ui/controllers/consumers/consumers_controller.rb', line 48

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

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

  paginate(@params.current_page, !last_page)

  render
end

#performanceObject

Displays per-process performance details



63
64
65
66
67
# File 'lib/karafka/web/pro/ui/controllers/consumers/consumers_controller.rb', line 63

def performance
  index

  render
end

#subscriptions(process_id) ⇒ Object

Parameters:

  • process_id (String)

    id of the process we’re interested in



78
79
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 78

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)

    refine(consumer_group)
  end

  render
end