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'); + }); } }