Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8824f711bb | |||
| f2d97832b5 | |||
| 855e57a651 |
@@ -4,6 +4,7 @@ namespace Kiri\Rpc;
|
||||
|
||||
|
||||
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Throwable;
|
||||
|
||||
class InvalidRpcParamsException extends \Exception
|
||||
@@ -15,7 +16,7 @@ class InvalidRpcParamsException extends \Exception
|
||||
* @param int $code
|
||||
* @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);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,6 @@ abstract class JsonRpcConsumers implements OnRpcConsumerInterface
|
||||
/**
|
||||
* @param array $data
|
||||
* @return ServerRequestInterface
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
private function requestBody(array $data): ServerRequestInterface
|
||||
{
|
||||
|
||||
+6
-6
@@ -57,13 +57,13 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa
|
||||
*/
|
||||
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');
|
||||
|
||||
$this->eventProvider->on(OnWorkerStart::class, [$this, 'consulWatches']);
|
||||
$this->eventProvider->on(OnWorkerExit::class, [$this, 'onWorkerExit']);
|
||||
$this->eventProvider->on(OnServerBeforeStart::class, [$this, 'register']);
|
||||
$this->getEventProvider()->on(OnWorkerStart::class, [$this, 'consulWatches']);
|
||||
$this->getEventProvider()->on(OnWorkerExit::class, [$this, 'onWorkerExit']);
|
||||
$this->getEventProvider()->on(OnServerBeforeStart::class, [$this, 'register']);
|
||||
|
||||
$this->manager = Kiri::getDi()->get(RpcManager::class);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa
|
||||
public function onBeforeShutdown(OnBeforeShutdown $beforeShutdown)
|
||||
{
|
||||
$doneList = $this->manager->doneList();
|
||||
$agent = $this->container->get(Agent::class);
|
||||
$agent = $this->getContainer()->get(Agent::class);
|
||||
foreach ($doneList as $value) {
|
||||
$agent->service->deregister($value['config']['ID']);
|
||||
$agent->checks->deregister($value['config']['Check']['CheckId']);
|
||||
@@ -207,7 +207,7 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa
|
||||
private function dispatch($data): array
|
||||
{
|
||||
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)) {
|
||||
throw new \Exception('Method not found', -32601);
|
||||
} else {
|
||||
|
||||
+1
-2
@@ -11,8 +11,7 @@
|
||||
"require": {
|
||||
"php": ">=8.0",
|
||||
"ext-json": "*",
|
||||
"psr/http-client": "^1.0",
|
||||
"psr/http-message": "^1.0"
|
||||
"psr/http-client": "^1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
Reference in New Issue
Block a user