This commit is contained in:
2020-10-12 12:57:32 +08:00
parent 3f4a44e9fd
commit 3d09da1688
+5 -2
View File
@@ -66,10 +66,13 @@ class Kafka extends \Snowflake\Process\Process
*/ */
public function channelListener($config) public function channelListener($config)
{ {
$this->channel = new Channel($config['size'] ?? 100); if (!isset($config['size'])) {
$config['size'] = 100;
}
$this->channel = new Channel($config['size']);
Coroutine::create(function () use ($config) { Coroutine::create(function () use ($config) {
$group = new WaitGroup(); $group = new WaitGroup();
for ($i = 0; $i < $config['size'] ?? 100; $i++) { for ($i = 0; $i < $config['size']; $i++) {
$group->add(); $group->add();
go(function () use ($group) { go(function () use ($group) {
defer(function () use ($group) { defer(function () use ($group) {