Sha256: a781c8853a287bb45715defd0b7928dc0e14ea64b735c03a251af804885c4908

Contents?: true

Size: 1.12 KB

Versions: 12

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Karafka
  module Setup
    class Configurators
      # Class responsible for setting up WaterDrop configuration
      class WaterDrop < Base
        # Sets up a WaterDrop settings
        # @param config [Karafka::Setup::Config] Config we can user to setup things
        # @note This will also inject Karafka monitor as a default monitor into WaterDrop,
        #   so we have the same monitor within whole Karafka framework (same with logger)
        def self.setup(config)
          ::WaterDrop.setup do |water_config|
            water_config.deliver = true

            config.to_h.reject { |k, _v| k == :kafka }.each do |k, v|
              key_assignment = :"#{k}="
              next unless water_config.respond_to?(key_assignment)
              water_config.public_send(key_assignment, v)
            end

            config.kafka.to_h.each do |k, v|
              key_assignment = :"#{k}="
              next unless water_config.kafka.respond_to?(key_assignment)
              water_config.kafka.public_send(key_assignment, v)
            end
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
karafka-1.2.13 lib/karafka/setup/configurators/water_drop.rb
karafka-1.2.12 lib/karafka/setup/configurators/water_drop.rb
karafka-1.2.11 lib/karafka/setup/configurators/water_drop.rb
karafka-1.2.10 lib/karafka/setup/configurators/water_drop.rb
karafka-1.2.9 lib/karafka/setup/configurators/water_drop.rb
karafka-1.2.8 lib/karafka/setup/configurators/water_drop.rb
karafka-1.2.7 lib/karafka/setup/configurators/water_drop.rb
karafka-1.2.6 lib/karafka/setup/configurators/water_drop.rb
karafka-1.2.5 lib/karafka/setup/configurators/water_drop.rb
karafka-1.2.4 lib/karafka/setup/configurators/water_drop.rb
karafka-1.2.3 lib/karafka/setup/configurators/water_drop.rb
karafka-1.2.2 lib/karafka/setup/configurators/water_drop.rb