This repository has been archived by the owner on Jan 17, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(code-coverage): Gather code coverage in server processes
- Loading branch information
Showing
22 changed files
with
410 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace K911\Swoole\Server\Configurator; | ||
|
||
use K911\Swoole\Server\LifecycleHandler\ServerShutdownHandlerInterface; | ||
use Swoole\Http\Server; | ||
|
||
final class WithServerShutdownHandler implements ConfiguratorInterface | ||
{ | ||
private $handler; | ||
|
||
public function __construct(ServerShutdownHandlerInterface $handler) | ||
{ | ||
$this->handler = $handler; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function configure(Server $server): void | ||
{ | ||
$server->on('shutdown', [$this->handler, 'handle']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace K911\Swoole\Server\Configurator; | ||
|
||
use K911\Swoole\Server\WorkerHandler\WorkerStopHandlerInterface; | ||
use Swoole\Http\Server; | ||
|
||
final class WithWorkerStopHandler implements ConfiguratorInterface | ||
{ | ||
private $handler; | ||
|
||
public function __construct(WorkerStopHandlerInterface $handler) | ||
{ | ||
$this->handler = $handler; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function configure(Server $server): void | ||
{ | ||
$server->on('close', [$this->handler, 'handle']); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Server/LifecycleHandler/ServerShutdownHandlerInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace K911\Swoole\Server\LifecycleHandler; | ||
|
||
use Swoole\Server; | ||
|
||
interface ServerShutdownHandlerInterface | ||
{ | ||
/** | ||
* Handle "OnShutdown" event. | ||
* | ||
* @param Server $server | ||
*/ | ||
public function handle(Server $server): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace K911\Swoole\Server\WorkerHandler; | ||
|
||
use Swoole\Server; | ||
|
||
class NoOpWorkerStartHandler implements WorkerStartHandlerInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function handle(Server $worker, int $workerId): void | ||
{ | ||
// noop | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace K911\Swoole\Server\WorkerHandler; | ||
|
||
use Swoole\Server; | ||
|
||
class NoOpWorkerStopHandler implements WorkerStopHandlerInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function handle(Server $worker, int $workerId): void | ||
{ | ||
// noop | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace K911\Swoole\Server\WorkerHandler; | ||
|
||
use Swoole\Server; | ||
|
||
interface WorkerStopHandlerInterface | ||
{ | ||
/** | ||
* Handle onWorkerStop event. | ||
* Info: Function will be executed in worker process | ||
* Warning: The abnormal stop of worker process will not trigger the event workerstop, for example, fatal error, core dump. | ||
* | ||
* @param Server $worker | ||
* @param int $workerId | ||
*/ | ||
public function handle(Server $worker, int $workerId): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.