From f0f8fc6d69341653285f2c5b9f6417a977914225 Mon Sep 17 00:00:00 2001 From: lamson <171004297@qq.com> Date: Thu, 1 Feb 2024 02:45:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96consumer=E5=87=8F?= =?UTF-8?q?=E5=B0=91=E8=BF=9E=E6=8E=A5=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Consumer/BaseTrait.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Consumer/BaseTrait.php b/src/Consumer/BaseTrait.php index d72ed25..8d32137 100644 --- a/src/Consumer/BaseTrait.php +++ b/src/Consumer/BaseTrait.php @@ -71,14 +71,14 @@ public function run($arg) EventMainServerCreate::listenProcessInfo(); } + // TODO 待优化为移入addTick并从sysinfo取? // 分片处理 $queues = $this->getListenQueues(); - foreach ($queues as $queue) { - $this->addTick($this->args['tick'] ?? 1000, function () use ($queue) { - - RedisPool::invoke(function (Redis $Redis) use ($queue) { + $this->addTick($this->args['tick'] ?? 1000, function () use ($queues) { + RedisPool::invoke(function (Redis $Redis) use ($queues) { + foreach ($queues as $queue) { for ($i = 0; $i < $this->args['limit'] ?? 200; ++$i) { $data = $Redis->lPop($queue); if ( ! $data) { @@ -93,8 +93,8 @@ public function run($arg) Trigger::getInstance()->throwable($throwable); } } - }, $this->args['pool'] ?? 'default'); - }); - } + } + }, $this->args['pool'] ?? 'default'); + }); } }