Class: Karafka::Web::Pro::Ui::Controllers::CommandsController
- Inherits:
-
BaseController
- Object
- Ui::Controllers::BaseController
- BaseController
- Karafka::Web::Pro::Ui::Controllers::CommandsController
- Defined in:
- lib/karafka/web/pro/ui/controllers/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 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
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
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/karafka/web/pro/ui/controllers/commands_controller.rb', line 22 def index @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
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/karafka/web/pro/ui/controllers/commands_controller.rb', line 58 def recent # 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
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/karafka/web/pro/ui/controllers/commands_controller.rb', line 46 def show(offset) @schema_version = Commanding::Dispatcher::SCHEMA_VERSION @command_message = Models::Message.find( commands_topic, 0, offset ) render end |