Class: Sbmt::KafkaProducer::KafkaClientFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/sbmt/kafka_producer/kafka_client_factory.rb

Constant Summary collapse

CLIENTS_REGISTRY_MUTEX =
Mutex.new
CLIENTS_REGISTRY =
{}

Class Method Summary collapse

Class Method Details

.build(kafka_options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sbmt/kafka_producer/kafka_client_factory.rb', line 18

def build(kafka_options = {})
  return default_client if kafka_options.empty?

  fetch_client(kafka_options) do
    ConnectionPool::Wrapper.new do
      WaterDrop::Producer.new do |config|
        configure_client(config, kafka_options)
      end
    end
  end
end

.default_clientObject



10
11
12
13
14
15
16
# File 'lib/sbmt/kafka_producer/kafka_client_factory.rb', line 10

def default_client
  @default_client ||= ConnectionPool::Wrapper.new do
    WaterDrop::Producer.new do |config|
      configure_client(config)
    end
  end
end