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

Inherits:
BaseController show all
Includes:
Ui::Lib::Paginations
Defined in:
lib/karafka/web/pro/ui/controllers/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 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

#controlsObject

Displays processes with details + ability to manage



77
78
79
80
81
# File 'lib/karafka/web/pro/ui/controllers/consumers_controller.rb', line 77

def controls
  index

  render
end

#details(process_id) ⇒ Object

Parameters:

  • process_id (String)

    id of the process we’re interested in



84
85
86
87
88
89
# File 'lib/karafka/web/pro/ui/controllers/consumers_controller.rb', line 84

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

  render
end

#indexObject

Consumers list



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/karafka/web/pro/ui/controllers/consumers_controller.rb', line 55

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

#pending_jobs(process_id) ⇒ Object

Renders details about pending jobs

Parameters:

  • process_id (String)

    id of the process we’re interested in



107
108
109
110
111
112
113
114
115
# File 'lib/karafka/web/pro/ui/controllers/consumers_controller.rb', line 107

def pending_jobs(process_id)
  details(process_id)

  @pending_jobs = @process.jobs.pending

  refine(@pending_jobs)

  render
end

#performanceObject

Displays per-process performance details



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

def performance
  index

  render
end

#running_jobs(process_id) ⇒ Object

Renders details about running jobs

Parameters:

  • process_id (String)

    id of the process we’re interested in



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

def running_jobs(process_id)
  details(process_id)

  @running_jobs = @process.jobs.running

  refine(@running_jobs)

  render
end

#subscriptions(process_id) ⇒ Object

Parameters:

  • process_id (String)

    id of the process we’re interested in



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/karafka/web/pro/ui/controllers/consumers_controller.rb', line 118

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