Class: Karafka::Web::Pro::Ui::Controllers::Consumers::CommandsController
- Inherits:
-
BaseController
- Object
- Ui::Controllers::BaseController
- BaseController
- BaseController
- Karafka::Web::Pro::Ui::Controllers::Consumers::CommandsController
- Defined in:
- lib/karafka/web/pro/ui/controllers/consumers/commands_controller.rb
Overview
Controller for viewing details of dispatched commands and their results
Constant Summary
Constants inherited from Ui::Controllers::BaseController
Ui::Controllers::BaseController::Models
Instance Attribute Summary
Attributes inherited from Ui::Controllers::BaseController
Instance Method Summary collapse
-
#index ⇒ Object
Lists commands from the consumers commands topic.
-
#recent ⇒ Object
Displays the most recent available command message details.
-
#show(offset) ⇒ Object
Shows details about given command / result.
Methods inherited from Ui::Controllers::BaseController
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
#index ⇒ Object
Lists commands from the consumers commands topic
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/karafka/web/pro/ui/controllers/consumers/commands_controller.rb', line 15 def index features.commanding! @schema_version = Commanding::Dispatcher::SCHEMA_VERSION @watermark_offsets = Models::WatermarkOffsets.find(commands_topic, 0) previous_offset, @command_messages, next_offset = current_partition_data # If message is an array, it means it's a compacted dummy offset representation = @command_messages.map do || .is_a?(Array) ? .last : .offset end paginate( previous_offset, @params.current_offset, next_offset, ) render end |
#recent ⇒ Object
Displays the most recent available command message details
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/karafka/web/pro/ui/controllers/consumers/commands_controller.rb', line 55 def recent features.commanding! # We read 25 just in case there would be a lot of transactional noise = ::Karafka::Admin.read_topic(commands_topic, 0, 25) # We find the most recent (last since they are shipped in reverse order) recent = .reverse.find { || !.is_a?(Array) } return show(recent.offset) if recent # If nothing found, lets redirect user back to the commands list redirect( 'commands', warning: 'No recent commands available' ) end |
#show(offset) ⇒ Object
Shows details about given command / result
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/karafka/web/pro/ui/controllers/consumers/commands_controller.rb', line 41 def show(offset) features.commanding! @schema_version = Commanding::Dispatcher::SCHEMA_VERSION @command_message = Models::Message.find( commands_topic, 0, offset ) render end |