class WaterDrop::Config

Configuration object for setting up all options required by WaterDrop

Constants

KAFKA_DEFAULTS

Defaults for kafka settings, that will be overwritten only if not present already

Public Instance Methods

setup() { |config| ... } click to toggle source

Configuration method @yield Runs a block of code providing a config singleton instance to it @yieldparam [WaterDrop::Config] WaterDrop config instance

# File lib/waterdrop/config.rb, line 107
def setup
  configure do |config|
    yield(config)

    merge_kafka_defaults!(config)

    Contracts::Config.new.validate!(config.to_h, Errors::ConfigurationInvalidError)

    ::Rdkafka::Config.logger = config.logger
  end

  self
end

Private Instance Methods

merge_kafka_defaults!(config) click to toggle source

Propagates the kafka setting defaults unless they are already present This makes it easier to set some values that users usually don’t change but still allows them to overwrite the whole hash if they want to @param config [Karafka::Core::Configurable::Node] config of this producer

# File lib/waterdrop/config.rb, line 127
def merge_kafka_defaults!(config)
  KAFKA_DEFAULTS.each do |key, value|
    next if config.kafka.key?(key)

    config.kafka[key] = value
  end
end