改名
This commit is contained in:
@@ -98,7 +98,7 @@ class ServerManager
|
|||||||
*/
|
*/
|
||||||
public function initBaseServer($configs, int $daemon = 0): void
|
public function initBaseServer($configs, int $daemon = 0): void
|
||||||
{
|
{
|
||||||
$context = ServerManager::getContext();
|
$context = di(ServerManager::class);
|
||||||
foreach ($this->sortService($configs['ports']) as $config) {
|
foreach ($this->sortService($configs['ports']) as $config) {
|
||||||
$this->startListenerHandler($context, $config, $daemon);
|
$this->startListenerHandler($context, $config, $daemon);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,11 +213,11 @@ abstract class BaseApplication extends Component
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TaskExecute $execute
|
* @param TaskExecute $execute
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException|NotFindClassException
|
||||||
*/
|
*/
|
||||||
public function task(TaskExecute $execute): void
|
public function task(TaskExecute $execute): void
|
||||||
{
|
{
|
||||||
ServerManager::getContext()->task($execute);
|
di(ServerManager::class)->task($execute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -400,10 +400,11 @@ abstract class BaseApplication extends Component
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Swoole\Http\Server|\Swoole\Server|\Swoole\WebSocket\Server|null
|
* @return \Swoole\Http\Server|\Swoole\Server|\Swoole\WebSocket\Server|null
|
||||||
|
* @throws
|
||||||
*/
|
*/
|
||||||
public function getSwoole(): \Swoole\Http\Server|\Swoole\Server|\Swoole\WebSocket\Server|null
|
public function getSwoole(): \Swoole\Http\Server|\Swoole\Server|\Swoole\WebSocket\Server|null
|
||||||
{
|
{
|
||||||
return ServerManager::getContext()->getServer();
|
return di(ServerManager::class)->getServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ class Async extends Component
|
|||||||
*/
|
*/
|
||||||
public function dispatch(string $name, array $params = [])
|
public function dispatch(string $name, array $params = [])
|
||||||
{
|
{
|
||||||
$context = ServerManager::getContext();
|
$context = di(ServerManager::class);
|
||||||
$context->task(static::$_absences[$name], $params);
|
$context->task(static::$_absences[$name], $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class Zookeeper implements CustomProcess
|
|||||||
if (empty($handler = $redis->get('crontab:' . $value))) {
|
if (empty($handler = $redis->get('crontab:' . $value))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$server = ServerManager::getContext()->getServer();
|
$server = di(ServerManager::class)->getServer();
|
||||||
$server->sendMessage(swoole_unserialize($handler), $this->getWorker());
|
$server->sendMessage(swoole_unserialize($handler), $this->getWorker());
|
||||||
} catch (Throwable $exception) {
|
} catch (Throwable $exception) {
|
||||||
logger()->addError($exception);
|
logger()->addError($exception);
|
||||||
@@ -92,7 +92,7 @@ class Zookeeper implements CustomProcess
|
|||||||
private function getWorker(): int
|
private function getWorker(): int
|
||||||
{
|
{
|
||||||
if ($this->workerNum == 0) {
|
if ($this->workerNum == 0) {
|
||||||
$server = ServerManager::getContext()->getServer();
|
$server = di(ServerManager::class)->getServer();
|
||||||
|
|
||||||
$this->workerNum = $server->setting['worker_num'] + ($server->setting['task_worker_num'] ?? 0);
|
$this->workerNum = $server->setting['worker_num'] + ($server->setting['task_worker_num'] ?? 0);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -446,7 +446,7 @@ class Kiri
|
|||||||
*/
|
*/
|
||||||
public static function async(string $class, array $params = [])
|
public static function async(string $class, array $params = [])
|
||||||
{
|
{
|
||||||
$manager = ServerManager::getContext();
|
$manager = di(ServerManager::class);
|
||||||
$manager->task(new $class(...$params));
|
$manager->task(new $class(...$params));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class Request extends HttpService implements RequestInterface
|
|||||||
*/
|
*/
|
||||||
public function getConnectInfo(): array|null
|
public function getConnectInfo(): array|null
|
||||||
{
|
{
|
||||||
$server = ServerManager::getContext()->getServer();
|
$server = di(ServerManager::class)->getServer();
|
||||||
|
|
||||||
return $server->getClientInfo($this->getClientId());
|
return $server->getClientInfo($this->getClientId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,13 +82,14 @@ class Response extends HttpService implements ResponseInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws
|
||||||
*/
|
*/
|
||||||
public function getClientInfo(): mixed
|
public function getClientInfo(): mixed
|
||||||
{
|
{
|
||||||
if (!empty($this->_clientInfo)) {
|
if (!empty($this->_clientInfo)) {
|
||||||
return $this->_clientInfo;
|
return $this->_clientInfo;
|
||||||
}
|
}
|
||||||
$server = ServerManager::getContext()->getServer();
|
$server = di(ServerManager::class)->getServer();
|
||||||
return $server->getClientInfo($this->clientId, $this->reactorId);
|
return $server->getClientInfo($this->clientId, $this->reactorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,13 @@ class Server extends HttpService
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
private ServerManager $manager;
|
/**
|
||||||
|
* @Inject ServerManager
|
||||||
|
* @var null|ServerManager
|
||||||
|
*/
|
||||||
|
#[Inject(ServerManager::class)]
|
||||||
|
private ?ServerManager $manager = null;
|
||||||
|
|
||||||
private mixed $daemon = 0;
|
private mixed $daemon = 0;
|
||||||
|
|
||||||
|
|
||||||
@@ -50,7 +56,6 @@ class Server extends HttpService
|
|||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->manager = ServerManager::getContext();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class Shutdown extends Component
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$server = ServerManager::getContext()->getServer();
|
$server = di(ServerManager::class)->getServer();
|
||||||
$master_pid = $server->setting['pid_file'] ?? PID_PATH;
|
$master_pid = $server->setting['pid_file'] ?? PID_PATH;
|
||||||
if (file_exists($master_pid)) {
|
if (file_exists($master_pid)) {
|
||||||
$this->close(file_get_contents($master_pid));
|
$this->close(file_get_contents($master_pid));
|
||||||
@@ -77,7 +77,7 @@ class Shutdown extends Component
|
|||||||
*/
|
*/
|
||||||
public function isRunning(): bool
|
public function isRunning(): bool
|
||||||
{
|
{
|
||||||
$server = ServerManager::getContext()->getServer();
|
$server = di(ServerManager::class)->getServer();
|
||||||
$master_pid = $server->setting['pid_file'] ?? PID_PATH;
|
$master_pid = $server->setting['pid_file'] ?? PID_PATH;
|
||||||
|
|
||||||
if (!file_exists($master_pid)) {
|
if (!file_exists($master_pid)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user