Class: Karafka::Web::Pro::Ui::Controllers::MessagesController
- Inherits:
-
BaseController
- Object
- Ui::Controllers::BaseController
- BaseController
- Karafka::Web::Pro::Ui::Controllers::MessagesController
- Defined in:
- lib/karafka/web/pro/ui/controllers/messages_controller.rb
Overview
Controller for working with messages While part of messages operations is done via explorer (exploring), this controller handles other cases not related to viewing data
Constant Summary
Constants inherited from Ui::Controllers::BaseController
Ui::Controllers::BaseController::Models
Instance Method Summary collapse
-
#download(topic_id, partition_id, offset) ⇒ Object
Dispatches the message raw payload to the browser as a file.
-
#export(topic_id, partition_id, offset) ⇒ Object
Dispatches the message payload first deserialized and then serialized to JSON It differs from the raw payload in cases where raw payload is compressed or binary or contains data that the Web UI user should not see that was altered on the Web UI with the visibility filter.
-
#republish(topic_id, partition_id, offset) ⇒ Object
Takes a requested message content and republishes it again.
Methods inherited from Ui::Controllers::BaseController
Constructor Details
This class inherits a constructor from Karafka::Web::Ui::Controllers::BaseController
Instance Method Details
#download(topic_id, partition_id, offset) ⇒ Object
Dispatches the message raw payload to the browser as a file
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/karafka/web/pro/ui/controllers/messages_controller.rb', line 52 def download(topic_id, partition_id, offset) = Models::Message.find(topic_id, partition_id, offset) deny! unless visibility_filter.download?() file( .raw_payload, "#{topic_id}_#{partition_id}_#{offset}_payload.msg" ) end |
#export(topic_id, partition_id, offset) ⇒ Object
Dispatches the message payload first deserialized and then serialized to JSON It differs from the raw payload in cases where raw payload is compressed or binary or contains data that the Web UI user should not see that was altered on the Web UI with the visibility filter.
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/karafka/web/pro/ui/controllers/messages_controller.rb', line 71 def export(topic_id, partition_id, offset) Lib::PatternsDetector.new.call = Models::Message.find(topic_id, partition_id, offset) # Check if exports are allowed deny! unless visibility_filter.export?() file( .payload.to_json, "#{topic_id}_#{partition_id}_#{offset}_payload.json" ) end |
#republish(topic_id, partition_id, offset) ⇒ Object
Takes a requested message content and republishes it again
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/karafka/web/pro/ui/controllers/messages_controller.rb', line 28 def republish(topic_id, partition_id, offset) = Models::Message.find(topic_id, partition_id, offset) deny! unless visibility_filter.republish?() delivery = ::Karafka::Web.producer.produce_sync( topic: topic_id, partition: partition_id, payload: .raw_payload, headers: .headers, key: .key ) redirect( :back, success: reproduced(, delivery) ) end |