From 688b2381daf5073c3768635eadfb1c1d8b1ee085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Wed, 23 Feb 2022 16:32:08 +0800 Subject: [PATCH] modify plugin name --- Annotation/JsonRpc.php | 4 ++-- RpcJsonp.php | 17 +++++++++++------ RpcManager.php | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Annotation/JsonRpc.php b/Annotation/JsonRpc.php index 7c235a9..d525ca3 100644 --- a/Annotation/JsonRpc.php +++ b/Annotation/JsonRpc.php @@ -7,10 +7,10 @@ use Kiri\Core\Network; use Kiri\Exception\ConfigException; use Kiri; use Kiri\Rpc\RpcManager; -use Kiri\Annotation\Attribute; +use Kiri\Annotation\AbstractAttribute; use ReflectionException; -#[\Attribute(\Attribute::TARGET_CLASS)] class JsonRpc extends Attribute +#[\Attribute(\Attribute::TARGET_CLASS)] class JsonRpc extends AbstractAttribute { diff --git a/RpcJsonp.php b/RpcJsonp.php index c56fdc7..4e70d82 100644 --- a/RpcJsonp.php +++ b/RpcJsonp.php @@ -25,6 +25,7 @@ use Kiri\Server\Events\OnWorkerStart; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; use Psr\Http\Message\ServerRequestInterface; +use ReflectionException; use Swoole\Coroutine; use Swoole\Coroutine\Channel; use Swoole\Server; @@ -51,19 +52,23 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa private int $timerId; + /** - * - * @throws \Exception + * @return void + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws ReflectionException */ public function init(): void { - $this->getEventProvider()->on(OnBeforeShutdown::class, [$this, 'onBeforeShutdown']); + $provider = $this->getEventProvider(); + $provider->on(OnBeforeShutdown::class, [$this, 'onBeforeShutdown']); scan_directory(APP_PATH . 'rpc', 'app\Rpc'); - $this->getEventProvider()->on(OnWorkerStart::class, [$this, 'consulWatches']); - $this->getEventProvider()->on(OnWorkerExit::class, [$this, 'onWorkerExit']); - $this->getEventProvider()->on(OnServerBeforeStart::class, [$this, 'register']); + $provider->on(OnWorkerStart::class, [$this, 'consulWatches']); + $provider->on(OnWorkerExit::class, [$this, 'onWorkerExit']); + $provider->on(OnServerBeforeStart::class, [$this, 'register']); $this->manager = Kiri::getDi()->get(RpcManager::class); } diff --git a/RpcManager.php b/RpcManager.php index 6562ec0..7267cef 100644 --- a/RpcManager.php +++ b/RpcManager.php @@ -74,7 +74,7 @@ class RpcManager extends Component $this->async($name); } } catch (\Throwable $throwable) { - $this->logger()->error(error_trigger_format($throwable)); + $this->logger->error(error_trigger_format($throwable)); } }