Class: WaterDrop::Producer::Builder
- Inherits:
-
Object
- Object
- WaterDrop::Producer::Builder
- Defined in:
- lib/waterdrop/producer/builder.rb
Overview
Class used to construct the rdkafka producer client
Instance Method Summary collapse
-
#call(producer, config) ⇒ Rdkafka::Producer, Producer::DummyClient
Raw rdkafka producer or a dummy producer when we don't want to dispatch any messages.
Instance Method Details
#call(producer, config) ⇒ Rdkafka::Producer, Producer::DummyClient
Returns raw rdkafka producer or a dummy producer when we don't want to dispatch any messages.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/waterdrop/producer/builder.rb', line 12 def call(producer, config) return DummyClient.new unless config.deliver client = Rdkafka::Config.new(config.kafka.to_h).producer # This callback is not global and is per client, thus we do not have to wrap it with a # callbacks manager to make it work client.delivery_callback = Instrumentation::Callbacks::Delivery.new( producer.id, config.monitor ) client end |