Sha256: 8542ecbfa8da0e5991252988f06a9a37591dde6371b1fb2a8e30561a71e5e373

Contents?: true

Size: 1.1 KB

Versions: 6

Compression:

Stored size: 1.1 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.except(: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

6 entries across 6 versions & 1 rubygems

Version Path
karafka-1.2.1 lib/karafka/setup/configurators/water_drop.rb
karafka-1.2.0 lib/karafka/setup/configurators/water_drop.rb
karafka-1.2.0.beta4 lib/karafka/setup/configurators/water_drop.rb
karafka-1.2.0.beta3 lib/karafka/setup/configurators/water_drop.rb
karafka-1.2.0.beta2 lib/karafka/setup/configurators/water_drop.rb
karafka-1.2.0.beta1 lib/karafka/setup/configurators/water_drop.rb