lib/deimos/backends/base.rb in deimos-ruby-1.24.2 vs lib/deimos/backends/base.rb in deimos-ruby-2.0.0.pre.alpha1
- old
+ new
@@ -4,57 +4,26 @@
module Backends
# Abstract class for all publish backends.
class Base
class << self
# @param producer_class [Class<Deimos::Producer>]
- # @param messages [Array<Deimos::Message>]
+ # @param messages [Array<Hash>]
# @return [void]
def publish(producer_class:, messages:)
- Deimos.config.logger.info(log_message(messages))
+ message = ::Deimos::Logging.messages_log_text(producer_class.karafka_config.payload_log, messages)
+ Deimos::Logging.log_info({message: 'Publishing Messages:'}.merge(message))
execute(producer_class: producer_class, messages: messages)
end
# @param producer_class [Class<Deimos::Producer>]
# @param messages [Array<Deimos::Message>]
# @return [void]
def execute(producer_class:, messages:)
- raise NotImplementedError
+ raise MissingImplementationError
end
private
- def log_message(messages)
- log_message = {
- message: 'Publishing messages',
- topic: messages.first&.topic
- }
-
- case Deimos.config.payload_log
- when :keys
- log_message.merge!(
- payload_keys: messages.map(&:key)
- )
- when :count
- log_message.merge!(
- payloads_count: messages.count
- )
- when :headers
- log_message.merge!(
- payload_headers: messages.map(&:headers)
- )
- else
- log_message.merge!(
- payloads: messages.map do |message|
- {
- payload: message.payload,
- key: message.key
- }
- end
- )
- end
-
- log_message
- end
end
end
end
end