From 0e0376ce67b5e7cb48dfb42acc2892f8a7408bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 23 Aug 2021 11:08:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kafka/KafkaClient.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Kafka/KafkaClient.php b/Kafka/KafkaClient.php index 1d6e7ae2..2fae8445 100644 --- a/Kafka/KafkaClient.php +++ b/Kafka/KafkaClient.php @@ -29,11 +29,12 @@ class KafkaClient /** * Producer constructor. * @param string $topic + * @param string $groupId + * @throws ConfigException * @throws NotFindClassException * @throws ReflectionException - * @throws ConfigException */ - public function __construct(public string $topic) + public function __construct(public string $topic, public string $groupId) { $this->conf = di(Conf::class); $this->topicConf = di(TopicConf::class); @@ -51,7 +52,7 @@ class KafkaClient throw new ConfigException('Please configure relevant information.'); } $kafkaConfig->set('metadata.broker.list', $config['brokers']); - $kafkaConfig->set('group.id', $config['groupId']); + $kafkaConfig->set('group.id', $this->groupId); $kafkaConfig->setErrorCb(function ($kafka, $err, $reason) { logger()->error(sprintf("Kafka error: %s (reason: %s)", rd_kafka_err2str($err), $reason)); });