Skip to content

Commit c513e46

Browse files
committed
feat: worker control
1 parent 6ba5257 commit c513e46

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

composer.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/DNS/Adapter/Swoole.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@ class Swoole extends Adapter
1515

1616
protected string $host;
1717
protected int $port;
18+
protected int $numWorkers;
19+
protected int $maxCoroutines;
1820

19-
public function __construct(string $host = '0.0.0.0', int $port = 53)
21+
public function __construct(string $host = '0.0.0.0', int $port = 53, int $numWorkers = 1, int $maxCoroutines = 3000)
2022
{
2123
$this->host = $host;
2224
$this->port = $port;
25+
$this->numWorkers = $numWorkers;
26+
$this->maxCoroutines = $maxCoroutines;
2327
$this->server = new Server($this->host, $this->port, SWOOLE_PROCESS, SWOOLE_SOCK_UDP);
28+
$this->server->set([
29+
'worker_num' => $this->numWorkers,
30+
'max_coroutine' => $this->maxCoroutines,
31+
]);
2432
}
2533

2634
/**

0 commit comments

Comments
 (0)