Sha256: ab309792f0bd20cba268e6bb1b0949bd1fc6ed3c0b1e34c7866c63ace25505df

Contents?: true

Size: 1010 Bytes

Versions: 1

Compression:

Stored size: 1010 Bytes

Contents

require "kafka/broker_pool"
require "kafka/producer"

module Kafka
  class Client

    # Initializes a new Kafka client.
    #
    # @param seed_brokers [Array<String>] the list of brokers used to initialize
    #   the client.
    #
    # @param client_id [String] the identifier for this application.
    #
    # @param logger [Logger]
    #
    # @param socket_timeout [Integer, nil] the timeout setting for socket
    #   connections. See {BrokerPool#initialize}.
    #
    # @return [Client]
    def initialize(seed_brokers:, client_id:, logger:, socket_timeout: nil)
      @seed_brokers = seed_brokers
      @client_id = client_id
      @logger = logger
      @socket_timeout = socket_timeout
    end

    def get_producer(**options)
      broker_pool = BrokerPool.new(
        seed_brokers: @seed_brokers,
        client_id: @client_id,
        logger: @logger,
        socket_timeout: @socket_timeout,
      )

      Producer.new(broker_pool: broker_pool, logger: @logger, **options)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-kafka-0.1.0.pre.beta2 lib/kafka/client.rb