我试图实现 gem 的功能ruby-kafka
。
在尝试其中一个时,我遇到了connection_builder
. 我发现很难了解更多关于connection_builder
.I 的信息。我不知道需要作为 connection_builder 传递什么,尝试使用“localhost”传递它,但最终得到了错误。非常感谢您在此处解释什么是 connection_builder 或需要传递哪些值的任何帮助!下面是我正在尝试的代码片段
bp = Kafka::BrokerPool.new(connection_builder: "localhost:9092", logger: Rails.logger)
cluster = Kafka::Cluster.new(seed_brokers: ["localhost:9092"], logger: Rails.logger, resolve_seed_brokers: false, broker_pool: bp)
operation = Kafka::FetchOperation.new(cluster: cluster, logger: Rails.logger, min_bytes: 1,max_wait_time: 10)
operation.fetch_from_partition("test-drive", 6,offset: :latest, max_bytes: 100000)
operation.execute
Error:
Traceback (most recent call last):
1: from (irb):75:in `<main>'
NoMethodError (undefined method `hostname' for "localhost:9092":String)