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



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

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

  render
end

#indexObject

Consumers list



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/karafka/web/pro/ui/controllers/consumers/consumers_controller.rb', line 73

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



88
89
90
91
92
# File 'lib/karafka/web/pro/ui/controllers/consumers/consumers_controller.rb', line 88

def performance
  index

  render
end

#subscriptions(process_id) ⇒ Object

Parameters:

  • process_id (String)

    id of the process we're interested in



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/karafka/web/pro/ui/controllers/consumers/consumers_controller.rb', line 103

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