Sha256: 800d981f0a2431d7276305e144d381dde693459c4d5b6413b880dddf8c1e9aa9

Contents?: true

Size: 902 Bytes

Versions: 67

Compression:

Stored size: 902 Bytes

Contents

# frozen_string_literal: true

module Deimos
  module Backends
    # Default backend to produce to Kafka.
    class Kafka < Base
      include Phobos::Producer

      # Shut down the producer if necessary.
      def self.shutdown_producer
        producer.sync_producer_shutdown if producer.respond_to?(:sync_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.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

67 entries across 67 versions & 2 rubygems

Version Path
deimos-ruby-1.8.7 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.6 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.5 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.4 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.3 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.2 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.2.pre.beta2 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.2.pre.beta1 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.1.pre.beta9 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.1.pre.beta8 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.1.pre.beta7 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.1.pre.beta6 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.1.pre.beta5 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.1.pre.beta4 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.1.pre.beta3 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.1.pre.beta2 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.1.pre.beta1 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.0.pre.beta2 lib/deimos/backends/kafka.rb
deimos-ruby-1.8.0.pre.beta1 lib/deimos/backends/kafka.rb
deimos-ruby-1.7.0.pre.beta1 lib/deimos/backends/kafka.rb