-
Notifications
You must be signed in to change notification settings - Fork 0
Feat- worker start callback #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| version: '3' | ||
|
|
||
| services: | ||
| dns-server: | ||
| image: dns-dev | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ class Swoole extends Adapter | |
| protected Server $server; | ||
| protected string $host; | ||
| protected int $port; | ||
| protected $workerStartCallback = null; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add type annotation for the property. The Apply this diff to fix the type annotation: -protected $workerStartCallback = null;
+protected ?callable $workerStartCallback = null;🧰 Tools🪛 GitHub Actions: CodeQL[error] 13-13: PHPStan: Property Utopia\DNS\Adapter\Swoole::$workerStartCallback has no type specified. 🤖 Prompt for AI Agents |
||
|
|
||
| public function __construct(string $host = '0.0.0.0', int $port = 53) | ||
| { | ||
|
|
@@ -32,6 +33,29 @@ public function onPacket(callable $callback): void | |
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Set callback for worker start event | ||
| * | ||
| * @param callable $callback | ||
| */ | ||
| public function onWorkerStart(callable $callback): void | ||
| { | ||
| $this->workerStartCallback = $callback; | ||
| $this->server->on('WorkerStart', function ($server, $workerId) use ($callback) { | ||
| call_user_func($callback, $server, $workerId); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Get the server instance for configuration | ||
| * | ||
| * @return Server | ||
| */ | ||
| public function getServer(): Server | ||
| { | ||
| return $this->server; | ||
| } | ||
|
|
||
| /** | ||
| * Start the DNS server | ||
| */ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.