改名
This commit is contained in:
@@ -213,11 +213,11 @@ abstract class BaseApplication extends Component
|
||||
|
||||
/**
|
||||
* @param TaskExecute $execute
|
||||
* @throws ReflectionException
|
||||
* @throws ReflectionException|NotFindClassException
|
||||
*/
|
||||
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
|
||||
* @throws
|
||||
*/
|
||||
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 = [])
|
||||
{
|
||||
$context = ServerManager::getContext();
|
||||
$context = di(ServerManager::class);
|
||||
$context->task(static::$_absences[$name], $params);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class Zookeeper implements CustomProcess
|
||||
if (empty($handler = $redis->get('crontab:' . $value))) {
|
||||
return;
|
||||
}
|
||||
$server = ServerManager::getContext()->getServer();
|
||||
$server = di(ServerManager::class)->getServer();
|
||||
$server->sendMessage(swoole_unserialize($handler), $this->getWorker());
|
||||
} catch (Throwable $exception) {
|
||||
logger()->addError($exception);
|
||||
@@ -92,7 +92,7 @@ class Zookeeper implements CustomProcess
|
||||
private function getWorker(): int
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -446,7 +446,7 @@ class Kiri
|
||||
*/
|
||||
public static function async(string $class, array $params = [])
|
||||
{
|
||||
$manager = ServerManager::getContext();
|
||||
$manager = di(ServerManager::class);
|
||||
$manager->task(new $class(...$params));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user