mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 03:37:44 +08:00
Format code. (#1876)
This commit is contained in:
parent
db0d74b0e2
commit
dd0b262dc0
@ -66,7 +66,7 @@
|
||||
"php-amqplib/php-amqplib": "^2.7",
|
||||
"php-di/php-di": "^6.0",
|
||||
"php-di/phpdoc-reader": "^2.0.1",
|
||||
"phpstan/phpstan": "^0.12.18",
|
||||
"phpstan/phpstan": "0.12.25",
|
||||
"phpunit/phpunit": "^7.0.0",
|
||||
"predis/predis": "^1.1",
|
||||
"roave/better-reflection": "^4.0",
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
parameters:
|
||||
bootstrap: "bootstrap.php"
|
||||
# bootstrapFiles:
|
||||
# - "bootstrap.php"
|
||||
inferPrivatePropertyTypeFromConstructor: true
|
||||
treatPhpDocTypesAsCertain: true
|
||||
reportUnmatchedIgnoredErrors: false
|
||||
|
@ -103,7 +103,7 @@ abstract class AbstractProcess implements ProcessInterface
|
||||
public function bind($server): void
|
||||
{
|
||||
if (CoroutineServer::isCoroutineServer($server)) {
|
||||
$this->bindCoServer($server);
|
||||
$this->bindCoroutineServer($server);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class CoroutineServer implements ServerInterface
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var Coroutine\Server
|
||||
* @var Coroutine\Http\Server|Coroutine\Server
|
||||
*/
|
||||
protected $server;
|
||||
|
||||
@ -83,13 +83,18 @@ class CoroutineServer implements ServerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Swoole\Coroutine\Server|\Swoole\Coroutine\Http\Server
|
||||
* @return \Swoole\Coroutine\Http\Server|\Swoole\Coroutine\Server
|
||||
*/
|
||||
public function getServer()
|
||||
{
|
||||
return $this->server;
|
||||
}
|
||||
|
||||
public static function isCoroutineServer($server): bool
|
||||
{
|
||||
return $server instanceof Coroutine\Http\Server || $server instanceof Coroutine\Server;
|
||||
}
|
||||
|
||||
protected function initServer(ServerConfig $config): void
|
||||
{
|
||||
$servers = $config->getServers();
|
||||
@ -129,9 +134,4 @@ class CoroutineServer implements ServerInterface
|
||||
|
||||
throw new RuntimeException('Server type is invalid.');
|
||||
}
|
||||
|
||||
public static function isCoroutineServer($server): bool
|
||||
{
|
||||
return $server instanceof Coroutine\Http\Server || $server instanceof Coroutine\Server;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Server\Event;
|
||||
|
||||
use Hyperf\Server\ServerConfig;
|
||||
use Swoole\Coroutine\Server;
|
||||
|
||||
class CoroutineServerStart
|
||||
|
@ -11,6 +11,17 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Server\Event;
|
||||
|
||||
use Swoole\Coroutine\Server;
|
||||
|
||||
class CoroutineServerStop
|
||||
{
|
||||
/**
|
||||
* @var object|Server
|
||||
*/
|
||||
public $server;
|
||||
|
||||
public function __construct($server)
|
||||
{
|
||||
$this->server = $server;
|
||||
}
|
||||
}
|
||||
|
@ -54,10 +54,10 @@ class AfterWorkerStartListener implements ListenerInterface
|
||||
/** @var Port $server */
|
||||
foreach (ServerManager::list() as $name => [$type, $server]) {
|
||||
$listen = $server->host . ':' . $server->port;
|
||||
$sockType = $server->type;
|
||||
$type = value(function () use ($type, $sockType) {
|
||||
$type = value(function () use ($type, $server) {
|
||||
switch ($type) {
|
||||
case Server::SERVER_BASE:
|
||||
$sockType = $server->type;
|
||||
if (($sockType === SWOOLE_SOCK_TCP) || ($sockType === SWOOLE_SOCK_TCP6)) {
|
||||
return 'TCP';
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ namespace Hyperf\Signal\Listener;
|
||||
use Hyperf\Event\Contract\ListenerInterface;
|
||||
use Hyperf\Framework\Event\OnWorkerExit;
|
||||
use Hyperf\Process\Event\AfterProcessHandle;
|
||||
use Hyperf\Server\Event\CoroutineServerStop;
|
||||
use Hyperf\Signal\SignalManager;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
@ -34,6 +35,7 @@ class SignalDeregisterListener implements ListenerInterface
|
||||
return [
|
||||
OnWorkerExit::class,
|
||||
AfterProcessHandle::class,
|
||||
CoroutineServerStop::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ namespace Hyperf\Signal\Listener;
|
||||
use Hyperf\Event\Contract\ListenerInterface;
|
||||
use Hyperf\Framework\Event\BeforeWorkerStart;
|
||||
use Hyperf\Process\Event\BeforeProcessHandle;
|
||||
use Hyperf\Server\Event\CoroutineServerStart;
|
||||
use Hyperf\Signal\SignalHandlerInterface as SignalHandler;
|
||||
use Hyperf\Signal\SignalManager;
|
||||
use Psr\Container\ContainerInterface;
|
||||
@ -35,6 +36,7 @@ class SignalRegisterListener implements ListenerInterface
|
||||
return [
|
||||
BeforeWorkerStart::class,
|
||||
BeforeProcessHandle::class,
|
||||
CoroutineServerStart::class,
|
||||
];
|
||||
}
|
||||
|
||||
@ -44,7 +46,7 @@ class SignalRegisterListener implements ListenerInterface
|
||||
|
||||
$manager->init();
|
||||
$manager->listen(value(function () use ($event) {
|
||||
if ($event instanceof BeforeWorkerStart) {
|
||||
if ($event instanceof BeforeWorkerStart || $event instanceof CoroutineServerStart) {
|
||||
return SignalHandler::WORKER;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ if (! function_exists('retry')) {
|
||||
/**
|
||||
* Retry an operation a given number of times.
|
||||
*
|
||||
* @param int|float $times
|
||||
* @param float|int $times
|
||||
* @param int $sleep millisecond
|
||||
* @throws \Throwable
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user