3 Commits

Author SHA1 Message Date
as2252258 8824f711bb Revert "改名"
This reverts commit fdf58326
2022-01-20 19:04:16 +08:00
as2252258 f2d97832b5 Revert "改名"
This reverts commit fdf58326
2022-01-19 17:27:47 +08:00
as2252258 855e57a651 Revert "改名"
This reverts commit fdf58326
2022-01-19 16:39:29 +08:00
4 changed files with 9 additions and 10 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ namespace Kiri\Rpc;
use JetBrains\PhpStorm\Pure;
use Throwable; use Throwable;
class InvalidRpcParamsException extends \Exception class InvalidRpcParamsException extends \Exception
@@ -15,7 +16,7 @@ class InvalidRpcParamsException extends \Exception
* @param int $code * @param int $code
* @param Throwable|null $previous * @param Throwable|null $previous
*/ */
public function __construct($message = "", $code = 0, Throwable $previous = null) #[Pure] public function __construct(string $message = "", int $code = 0, Throwable $previous = null)
{ {
parent::__construct($message, -32602, $previous); parent::__construct($message, -32602, $previous);
} }
-1
View File
@@ -54,7 +54,6 @@ abstract class JsonRpcConsumers implements OnRpcConsumerInterface
/** /**
* @param array $data * @param array $data
* @return ServerRequestInterface * @return ServerRequestInterface
* @throws \ReflectionException
*/ */
private function requestBody(array $data): ServerRequestInterface private function requestBody(array $data): ServerRequestInterface
{ {
+6 -6
View File
@@ -57,13 +57,13 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa
*/ */
public function init(): void public function init(): void
{ {
$this->eventProvider->on(OnBeforeShutdown::class, [$this, 'onBeforeShutdown']); $this->getEventProvider()->on(OnBeforeShutdown::class, [$this, 'onBeforeShutdown']);
scan_directory(APP_PATH . 'rpc', 'app\Rpc'); scan_directory(APP_PATH . 'rpc', 'app\Rpc');
$this->eventProvider->on(OnWorkerStart::class, [$this, 'consulWatches']); $this->getEventProvider()->on(OnWorkerStart::class, [$this, 'consulWatches']);
$this->eventProvider->on(OnWorkerExit::class, [$this, 'onWorkerExit']); $this->getEventProvider()->on(OnWorkerExit::class, [$this, 'onWorkerExit']);
$this->eventProvider->on(OnServerBeforeStart::class, [$this, 'register']); $this->getEventProvider()->on(OnServerBeforeStart::class, [$this, 'register']);
$this->manager = Kiri::getDi()->get(RpcManager::class); $this->manager = Kiri::getDi()->get(RpcManager::class);
} }
@@ -78,7 +78,7 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa
public function onBeforeShutdown(OnBeforeShutdown $beforeShutdown) public function onBeforeShutdown(OnBeforeShutdown $beforeShutdown)
{ {
$doneList = $this->manager->doneList(); $doneList = $this->manager->doneList();
$agent = $this->container->get(Agent::class); $agent = $this->getContainer()->get(Agent::class);
foreach ($doneList as $value) { foreach ($doneList as $value) {
$agent->service->deregister($value['config']['ID']); $agent->service->deregister($value['config']['ID']);
$agent->checks->deregister($value['config']['Check']['CheckId']); $agent->checks->deregister($value['config']['Check']['CheckId']);
@@ -207,7 +207,7 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa
private function dispatch($data): array private function dispatch($data): array
{ {
try { try {
[$handler, $params] = $this->container->get(RpcManager::class)->get($data['service'], $data['method']); [$handler, $params] = $this->getContainer()->get(RpcManager::class)->get($data['service'], $data['method']);
if (is_null($handler)) { if (is_null($handler)) {
throw new \Exception('Method not found', -32601); throw new \Exception('Method not found', -32601);
} else { } else {
+1 -2
View File
@@ -11,8 +11,7 @@
"require": { "require": {
"php": ">=8.0", "php": ">=8.0",
"ext-json": "*", "ext-json": "*",
"psr/http-client": "^1.0", "psr/http-client": "^1.0"
"psr/http-message": "^1.0"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {