Class: ChiliLogger::UnpublishedLogsManager
- Inherits:
-
Object
- Object
- ChiliLogger::UnpublishedLogsManager
- Defined in:
- lib/unpublished_logs_manager/unpublished_logs_manager.rb
Overview
class for manipulating unpublished logs that were sent to the fallback_broker
Instance Method Summary collapse
-
#initialize(msg_broker, logging_error_handler) ⇒ UnpublishedLogsManager
constructor
A new instance of UnpublishedLogsManager.
- #republish ⇒ Object
Constructor Details
#initialize(msg_broker, logging_error_handler) ⇒ UnpublishedLogsManager
Returns a new instance of UnpublishedLogsManager.
9 10 11 12 13 14 15 |
# File 'lib/unpublished_logs_manager/unpublished_logs_manager.rb', line 9 def initialize(msg_broker, logging_error_handler) validate_msg_broker_type(msg_broker) validate_logging_error_handler_type(logging_error_handler) @msg_broker = msg_broker @logging_error_handler = logging_error_handler end |
Instance Method Details
#republish ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/unpublished_logs_manager/unpublished_logs_manager.rb', line 17 def republish unpub_logs = @logging_error_handler.fetch_unpublished_logs unpub_logs.each do |unpub_log| fallback_broker_msg = unpub_log[:fallback_broker_msg] log = unpub_log[:log] # if a message can't be published by MainBroker, LoggingErrorHandler sends it to the fallback_broker # to avoid duplicates in this scenario, we delete the message before even trying to publish it @logging_error_handler.delete_unpublished_log(fallback_broker_msg) @msg_broker.publish(log) end end |