Class: Kafka::ConnectionBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/kafka/connection_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(client_id:, logger:, instrumenter:, connect_timeout:, socket_timeout:, ssl_context:, sasl_authenticator:) ⇒ ConnectionBuilder

Returns a new instance of ConnectionBuilder


5
6
7
8
9
10
11
12
13
# File 'lib/kafka/connection_builder.rb', line 5

def initialize(client_id:, logger:, instrumenter:, connect_timeout:, socket_timeout:, ssl_context:, sasl_authenticator:)
  @client_id = client_id
  @logger = TaggedLogger.new(logger)
  @instrumenter = instrumenter
  @connect_timeout = connect_timeout
  @socket_timeout = socket_timeout
  @ssl_context = ssl_context
  @sasl_authenticator = sasl_authenticator
end

Instance Method Details

#build_connection(host, port) ⇒ Object


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/kafka/connection_builder.rb', line 15

def build_connection(host, port)
  connection = Connection.new(
    host: host,
    port: port,
    client_id: @client_id,
    connect_timeout: @connect_timeout,
    socket_timeout: @socket_timeout,
    logger: @logger,
    instrumenter: @instrumenter,
    ssl_context: @ssl_context,
  )

  @sasl_authenticator.authenticate!(connection)

  connection
end