From 08ac31267b42e80836bad0963f51c704b4fae20c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Sat, 20 Feb 2021 18:37:26 +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/Kafka.php | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/Kafka/Kafka.php b/Kafka/Kafka.php index 575ee7fc..664afe90 100644 --- a/Kafka/Kafka.php +++ b/Kafka/Kafka.php @@ -39,12 +39,7 @@ class Kafka extends \Snowflake\Process\Process */ public function onHandler(Process $process): void { -// $this->channelListener(); - $this->waite(json_decode($process->read(), true)); - Timer::tick(1000, function () { - $this->application->error('kafka service error.'); - }); } @@ -100,41 +95,6 @@ class Kafka extends \Snowflake\Process\Process } - /** - * 监听通道数据传递 - */ - public function channelListener() - { - $this->channel = new Channel($this->maxLength); - Coroutine::create(function () { - $group = new WaitGroup(); - for ($i = 0; $i < $this->maxLength; $i++) { - $group->add(); - go(function () use ($group) { - defer(function () use ($group) { - $group->done(); - }); - $this->popMessage(); - }); - } - $group->wait(); - }); - } - - - /** - * 优化执行方式 - */ - public function popMessage() - { - $messages = $this->channel->pop(-1); - if (!empty($messages)) { - $this->handlerExecute($messages[0], $messages[1]); - } - $this->popMessage(); - } - - /** * @param $topic * @param $message