Module: Karafka::Setup::DefaultsInjector
- Defined in:
- lib/karafka/setup/defaults_injector.rb
Overview
Injector that enriches each Kafka cluster with needed defaults. User may use more than one cluster and define them on a per-topic basis. We use this when we build the final config per subscription group.
Class Method Summary collapse
-
.consumer(kafka_config) ⇒ Object
Propagates the kafka setting defaults unless they are already present for consumer config 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.
-
.producer(kafka_config) ⇒ Object
Propagates the kafka settings defaults unless they are already present for producer config.
Class Method Details
.consumer(kafka_config) ⇒ Object
Propagates the kafka setting defaults unless they are already present for consumer config 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
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/karafka/setup/defaults_injector.rb', line 56 def consumer(kafka_config) CONSUMER_KAFKA_DEFAULTS.each do |key, value| next if kafka_config.key?(key) kafka_config[key] = value end return if Karafka::App.env.production? CONSUMER_KAFKA_DEV_DEFAULTS.each do |key, value| next if kafka_config.key?(key) kafka_config[key] = value end end |
.producer(kafka_config) ⇒ Object
Propagates the kafka settings defaults unless they are already present for producer config. This makes it easier to set some values that users usually don’t change but still allows them to overwrite the whole hash.
77 78 79 80 81 82 83 84 85 |
# File 'lib/karafka/setup/defaults_injector.rb', line 77 def producer(kafka_config) return if Karafka::App.env.production? PRODUCER_KAFKA_DEV_DEFAULTS.each do |key, value| next if kafka_config.key?(key) kafka_config[key] = value end end |