class ChiliLogger::UnpublishedLogsManager
class for manipulating unpublished logs that were sent to the fallback_broker
Public Class Methods
new(msg_broker, logging_error_handler)
click to toggle source
# 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
Public Instance Methods
republish()
click to toggle source
# 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
Private Instance Methods
validate_logging_error_handler_type(error_handler)
click to toggle source
# File lib/unpublished_logs_manager/unpublished_logs_manager.rb, line 40 def validate_logging_error_handler_type(error_handler) err_type = ChiliLogger::ConfigError err_msg = "#{error_handler} should be an instance of ChiliLogger::LoggingError::Handler" raise(err_type, err_msg) unless error_handler.class == ChiliLogger::LoggingErrorHandler end
validate_msg_broker_type(msg_broker)
click to toggle source
# File lib/unpublished_logs_manager/unpublished_logs_manager.rb, line 33 def validate_msg_broker_type(msg_broker) err_type = ChiliLogger::ConfigError err_msg = "#{msg_broker.inspect} should be an instance of ChiliLogger::MainBroker" raise(err_type, err_msg) unless msg_broker.class == ChiliLogger::MainBroker end