Class: Deimos::Backends::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/deimos/backends/base.rb

Overview

Abstract class for all publish backends.

Direct Known Subclasses

Db, Kafka, KafkaAsync, Test

Class Method Summary collapse

Class Method Details

.execute(producer_class:, messages:) ⇒ Object

Parameters:

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/deimos/backends/base.rb', line 26

def execute(producer_class:, messages:)
  raise NotImplementedError
end

.publish(producer_class:, messages:) ⇒ Object

Parameters:



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/deimos/backends/base.rb', line 10

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