From b4d0c95a807400939e4dab5e8dc1689e0b8107b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Wed, 20 Oct 2021 14:42:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kiri-engine/Cache/Base/Redis.php | 7 ----- kiri-engine/Pool/Pool.php | 7 +++++ kiri-note/LocalService.php | 54 -------------------------------- 3 files changed, 7 insertions(+), 61 deletions(-) delete mode 100644 kiri-note/LocalService.php diff --git a/kiri-engine/Cache/Base/Redis.php b/kiri-engine/Cache/Base/Redis.php index 02659959..d525e7c1 100644 --- a/kiri-engine/Cache/Base/Redis.php +++ b/kiri-engine/Cache/Base/Redis.php @@ -28,11 +28,6 @@ class Redis implements StopHeartbeatCheck private int $_transaction = 0; - /** - * @var EventProvider - */ - private EventProvider $eventProvider; - private int $_timer = -1; private int $_last = 0; @@ -51,14 +46,12 @@ class Redis implements StopHeartbeatCheck public string $auth = '', public string $prefix = '', public int $timeout = 30, public int $read_timeout = 30) { - $this->eventProvider = Kiri::getDi()->get(EventProvider::class); } public function init() { $this->heartbeat_check(); - $this->eventProvider->on(OnWorkerExit::class, [$this, 'stopHeartbeatCheck']); } diff --git a/kiri-engine/Pool/Pool.php b/kiri-engine/Pool/Pool.php index cb5a7317..10d597ab 100644 --- a/kiri-engine/Pool/Pool.php +++ b/kiri-engine/Pool/Pool.php @@ -218,6 +218,13 @@ class Pool extends Component if (!isset(static::$_connections[$name])) { return; } + /** @var Channel|SplQueue $connection */ + foreach (static::$_connections[$name] as $connection) { + $client = $connection->pop(); + if ($client instanceof StopHeartbeatCheck) { + $client->stopHeartbeatCheck(); + } + } static::$_connections[$name] = null; unset(static::$_connections[$name]); } diff --git a/kiri-note/LocalService.php b/kiri-note/LocalService.php deleted file mode 100644 index ef78aa4f..00000000 --- a/kiri-note/LocalService.php +++ /dev/null @@ -1,54 +0,0 @@ -async_reload !== true) { - $pro = di(EventProvider::class); - $pro->on(OnWorkerExit::class, function () { - di(\Kiri\Di\LocalService::class)->remove($this->service); - }, 0); - } - } - - - /** - * @param object $class - * @param string $method - * @return bool - * @throws Exception - */ - public function execute(mixed $class, mixed $method = null): bool - { - $class = ['class' => $class]; - if (!empty($this->args)) { - $class = array_merge($class, $this->args); - } - Kiri::set($this->service, $class); - return true; - } - -}