Class: Deimos::Backends::KafkaAsync
- Includes:
- Phobos::Producer
- Defined in:
- lib/deimos/backends/kafka_async.rb
Overview
Backend which produces to Kafka via an async producer.
Class Method Summary collapse
-
.execute(producer_class:, messages:) ⇒ Object
:nodoc:.
-
.shutdown_producer ⇒ void
Shut down the producer cleanly.
Methods inherited from Base
Class Method Details
.execute(producer_class:, messages:) ⇒ Object
:nodoc:
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/deimos/backends/kafka_async.rb', line 17 def self.execute(producer_class:, messages:) Deimos.instrument( 'produce', producer: producer_class, topic: producer_class.topic, payloads: .map(&:payload) ) do producer.async_publish_list(.map(&:encoded_hash)) Deimos.config.metrics&.increment( 'publish', tags: %W(status:success topic:#{producer_class.topic}), by: .size ) end end |
.shutdown_producer ⇒ void
This method returns an undefined value.
Shut down the producer cleanly.
11 12 13 14 |
# File 'lib/deimos/backends/kafka_async.rb', line 11 def self.shutdown_producer producer.async_producer_shutdown producer.kafka_client&.close end |