Sha256: 61e898ac63e2c1299958ae8c32e885dbba2c636019141306691e27bfc1d2bb0a

Contents?: true

Size: 901 Bytes

Versions: 38

Compression:

Stored size: 901 Bytes

Contents

# frozen_string_literal: true

module Deimos
  module Backends
    # Backend which produces to Kafka via an async producer.
    class KafkaAsync < Base
      include Phobos::Producer

      # Shut down the producer cleanly.
      # @return [void]
      def self.shutdown_producer
        producer.async_producer_shutdown
        producer.kafka_client&.close
      end

      # :nodoc:
      def self.execute(producer_class:, messages:)
        Deimos.instrument(
          'produce',
          producer: producer_class,
          topic: producer_class.topic,
          payloads: messages.map(&:payload)
        ) do
          producer.async_publish_list(messages.map(&:encoded_hash))
          Deimos.config.metrics&.increment(
            'publish',
            tags: %W(status:success topic:#{producer_class.topic}),
            by: messages.size
          )
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
deimos-ruby-1.24.2 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.24.1 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.24.0 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.23.3 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.23.2 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.23.1.pre.beta6 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.23.1.pre.beta5 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.23.1.pre.beta4 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.23.1.pre.beta3 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.23.1.pre.beta2 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.23.1.pre.beta1 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.23.0 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.22.5 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.22.4 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.22.3 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.22.2 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.22.1 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.22 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.20.1 lib/deimos/backends/kafka_async.rb
deimos-ruby-1.20.0 lib/deimos/backends/kafka_async.rb