Class: Deimos::Backends::Kafka
- Includes:
- Phobos::Producer
- Defined in:
- lib/deimos/backends/kafka.rb
Overview
Default backend to produce to Kafka.
Class Method Summary collapse
-
.execute(producer_class:, messages:) ⇒ Object
:nodoc:.
-
.shutdown_producer ⇒ Object
Shut down the producer if necessary.
Methods inherited from Base
Class Method Details
.execute(producer_class:, messages:) ⇒ Object
:nodoc:
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/deimos/backends/kafka.rb', line 16 def self.execute(producer_class:, messages:) Deimos.instrument( 'produce', producer: producer_class, topic: producer_class.topic, payloads: .map(&:payload) ) do producer.publish_list(.map(&:encoded_hash)) Deimos.config.metrics&.increment( 'publish', tags: %W(status:success topic:#{producer_class.topic}), by: .size ) end end |
.shutdown_producer ⇒ Object
Shut down the producer if necessary.
10 11 12 13 |
# File 'lib/deimos/backends/kafka.rb', line 10 def self.shutdown_producer producer.sync_producer_shutdown if producer.respond_to?(:sync_producer_shutdown) producer.kafka_client&.close end |