Class: Karafka::Web::Pro::Ui::Controllers::ScheduledMessages::SchedulesController
- Inherits:
-
BaseController
- Object
- Ui::Controllers::BaseController
- BaseController
- BaseController
- Karafka::Web::Pro::Ui::Controllers::ScheduledMessages::SchedulesController
- Defined in:
- lib/karafka/web/pro/ui/controllers/scheduled_messages/schedules_controller.rb
Overview
Controller to display list of schedules (groups) and details about each
Constant Summary
Constants inherited from Ui::Controllers::BaseController
Ui::Controllers::BaseController::Models
Instance Method Summary collapse
-
#index ⇒ Object
Displays list of groups.
-
#show(schedule_name) ⇒ Object
Displays all partitions statistics (if any) with number of messages to dispatch.
Methods inherited from Ui::Controllers::BaseController
Constructor Details
This class inherits a constructor from Karafka::Web::Ui::Controllers::BaseController
Instance Method Details
#index ⇒ Object
Displays list of groups
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/karafka/web/pro/ui/controllers/scheduled_messages/schedules_controller.rb', line 24 def index topics = Models::Topic.all # Names of scheduled messages topics defined in the routing # They may not exist (yet) so we filter them based on the existing topics in the # cluster candidates = Karafka::App .routes .map(&:topics) .map(&:to_a) .flatten .select(&:scheduled_messages?) .reject { |topic| topic.name.end_with?(states_postfix) } .map(&:name) .sort @topics = topics.select { |topic| candidates.include?(topic.topic_name) } render end |
#show(schedule_name) ⇒ Object
Displays all partitions statistics (if any) with number of messages to dispatch
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/karafka/web/pro/ui/controllers/scheduled_messages/schedules_controller.rb', line 47 def show(schedule_name) @schedule_name = schedule_name @stats_topic_name = "#{schedule_name}#{states_postfix}" @stats_info = Karafka::Admin.topic_info(@stats_topic_name) @states = {} @stats_info[:partition_count].times { |i| @states[i] = false } Karafka::Pro::Iterator.new({ @stats_topic_name => -1 }).each do || @states[.partition] = .payload end # Sort by partition id @states = @states.sort_by { |key, _| key.to_s }.to_h # Sort daily from closest date @states.each_value do |details| # Skip false predefined values from sorting next unless details details[:daily] = details[:daily].sort_by { |key, _| key.to_s }.to_h end render end |