Sha256: d02923ce80b78a540295216952a3340e85f2ce843374a376eaba5008b3ba6ab9

Contents?: true

Size: 861 Bytes

Versions: 28

Compression:

Stored size: 861 Bytes

Contents

# frozen_string_literal: true

module Deimos
  # Abstract class for all publish backends.
  class PublishBackend
    class << self
      # @param producer_class [Class < Deimos::Producer]
      # @param messages [Array<Deimos::Message>]
      def publish(producer_class:, messages:)
        Deimos.config.logger.info(
          message: 'Publishing messages',
          topic: producer_class.topic,
          payloads: messages.map do |message|
            {
              payload: message.payload,
              key: message.key
            }
          end
        )
        execute(producer_class: producer_class, messages: messages)
      end

      # @param producer_class [Class < Deimos::Producer]
      # @param messages [Array<Deimos::Message>]
      def execute(producer_class:, messages:)
        raise NotImplementedError
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
deimos-ruby-1.0.0.pre.beta22 lib/deimos/publish_backend.rb
deimos-kafka-1.0.0.pre.beta21 lib/deimos/publish_backend.rb
deimos-kafka-1.0.0.pre.beta20 lib/deimos/publish_backend.rb
deimos-kafka-1.0.0.pre.beta19 lib/deimos/publish_backend.rb
deimos-kafka-1.0.0.pre.beta18 lib/deimos/publish_backend.rb
deimos-kafka-1.0.0.pre.beta17 lib/deimos/publish_backend.rb
deimos-kafka-1.0.0.pre.beta16 lib/deimos/publish_backend.rb
deimos-kafka-1.0.0.pre.beta15 lib/deimos/publish_backend.rb