Class: WaterDrop::Producer::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/waterdrop/producer/builder.rb

Overview

Class used to construct the rdkafka producer client

Instance Method Summary collapse

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.

Parameters:

  • producer (Producer)

    not yet configured producer for which we want to build the client

  • config (Object)

    dry-configurable based configuration object

Returns:

  • (Rdkafka::Producer, Producer::DummyClient)

    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
# File 'lib/waterdrop/producer/builder.rb', line 12

def call(producer, config)
  klass = config.client_class
  # This allows us to have backwards compatibility.
  # If it is the default client and delivery is set to false, we use dummy as we used to
  # before `client_class` was introduced
  klass = Clients::Dummy if klass == Clients::Rdkafka && !config.deliver

  klass.new(producer)
end