-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Messages reproduce and surrounding link (#104)
- Loading branch information
Showing
17 changed files
with
336 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module Karafka | ||
module Web | ||
module Ui | ||
module Controllers | ||
module Responses | ||
# Representation of a redirect response with optional flash messages | ||
class Redirect | ||
attr_reader :path, :flashes | ||
|
||
# @param path [String, Symbol] relative (without root path) path where we want to be | ||
# redirected or `:back` to use referer back | ||
# @param flashes [Hash] hash where key is the flash type and value is the message | ||
def initialize(path = :back, flashes = {}) | ||
@path = path | ||
@flashes = flashes | ||
end | ||
|
||
# @return [Boolean] are we going back via referer and not explicit path | ||
def back? | ||
@path == :back | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# frozen_string_literal: true | ||
|
||
# This Karafka component is a Pro component under a commercial license. | ||
# This Karafka component is NOT licensed under LGPL. | ||
# | ||
# All of the commercial components are present in the lib/karafka/pro directory of this | ||
# repository and their usage requires commercial license agreement. | ||
# | ||
# Karafka has also commercial-friendly license, commercial support and commercial components. | ||
# | ||
# By sending a pull request to the pro components, you are agreeing to transfer the copyright of | ||
# your code to Maciej Mensfeld. | ||
|
||
module Karafka | ||
module Web | ||
module Ui | ||
module Pro | ||
module Controllers | ||
# 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 | ||
class Messages < Ui::Controllers::Base | ||
# Takes a requested message content and republishes it again | ||
# | ||
# @param topic_id [String] | ||
# @param partition_id [Integer] | ||
# @param offset [Integer] offset of the message we want to republish | ||
def republish(topic_id, partition_id, offset) | ||
message = Ui::Models::Message.find(topic_id, partition_id, offset) | ||
|
||
delivery = ::Karafka.producer.produce_sync( | ||
topic: topic_id, | ||
partition: partition_id, | ||
payload: message.raw_payload, | ||
headers: message.headers, | ||
key: message.key | ||
) | ||
|
||
redirect( | ||
:back, | ||
success: reproduced(message, delivery) | ||
) | ||
end | ||
|
||
private | ||
|
||
# @param message [Karafka::Messages::Message] | ||
# @param delivery [Rdkafka::Producer::DeliveryReport] | ||
# @return [String] flash message about message reproducing | ||
def reproduced(message, delivery) | ||
<<~MSG | ||
Message with offset #{message.offset} | ||
has been sent again to #{message.topic}##{message.partition} | ||
and received offset #{delivery.offset}. | ||
MSG | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<% flash.each do |name, message| %> | ||
<div class="mb-4"> | ||
<div class="container"> | ||
<p class="alert alert-<%= name %>"> | ||
<%= message %> | ||
</p> | ||
</div> | ||
</div> | ||
<% end %> |
Oops, something went wrong.