modify plugin name

This commit is contained in:
2022-06-20 17:31:04 +08:00
parent 005b33c9d6
commit b0b7906135
4 changed files with 18 additions and 11 deletions
+8 -4
View File
@@ -5,9 +5,7 @@ namespace Kiri\Server\Abstracts;
use Kiri\Abstracts\Config;
use Kiri\Di\ContainerInterface;
use Kiri\Events\EventDispatch;
use Kiri\Exception\ConfigException;
use Kiri\Server\Constant;
use Kiri\Server\Events\OnShutdown;
use Kiri\Server\Events\OnWorkerStart;
use Kiri\Server\Events\OnWorkerStop;
use Kiri\Server\ServerInterface;
@@ -55,10 +53,16 @@ class CoroutineServer implements ServerInterface
/**
* @param string $name
* @return Server|\Swoole\Coroutine\Server|\Swoole\Coroutine\Http\Server|null
* @return Server|Coroutine\Server|Coroutine\Http\Server|null
*/
public function getServer(string $name): Server|\Swoole\Coroutine\Server|\Swoole\Coroutine\Http\Server|null
public function getServer(string $name = ''): Server|Coroutine\Server|Coroutine\Http\Server|null
{
if (empty($this->servers)) {
return null;
}
if (empty($name)) {
return current($this->servers);
}
return $this->servers[$name] ?? null;
}
+5 -3
View File
@@ -16,12 +16,14 @@ trait TraitServer
/**
* @param $class
* @param array $class
* @return void
*/
public function addProcess($class): void
public function addProcess(array $class): void
{
$this->_process[] = $class;
foreach ($class as $key => $item) {
$this->_process[] = $item;
}
}
+4 -3
View File
@@ -35,6 +35,7 @@ use Kiri\Message\Constrict\Response;
use Kiri\Message\Constrict\Request;
use Kiri\Server\Abstracts\ProcessManager;
use Kiri\Server\Abstracts\AsyncServer;
use Kiri\Server\Abstracts\CoroutineServer;
defined('PID_PATH') or define('PID_PATH', APP_PATH . 'storage/server.pid');
@@ -54,7 +55,7 @@ class Server extends HttpService
/**
* @param State $state
* @param AsyncServer $manager
* @param Abstracts\CoroutineServer $manager
* @param ContainerInterface $container
* @param ProcessManager $processManager
* @param EventDispatch $dispatch
@@ -64,7 +65,7 @@ class Server extends HttpService
* @throws Exception
*/
public function __construct(public State $state,
public AsyncServer $manager,
public CoroutineServer $manager,
public ContainerInterface $container,
public ProcessManager $processManager,
public EventDispatch $dispatch,
@@ -129,7 +130,7 @@ class Server extends HttpService
$this->onHotReload();
$this->processManager->batch($this->process, $this->manager->getServer());
$this->manager->addProcess($this->process);
$this->dispatch->dispatch(new OnServerBeforeStart());
$this->manager->start();
}
+1 -1
View File
@@ -16,7 +16,7 @@ interface ServerInterface
* @param string $name
* @return Server|\Swoole\Coroutine\Server|\Swoole\Coroutine\Http\Server|null
*/
public function getServer(string $name): Server|\Swoole\Coroutine\Server|\Swoole\Coroutine\Http\Server|null;
public function getServer(string $name = ''): Server|\Swoole\Coroutine\Server|\Swoole\Coroutine\Http\Server|null;
/**