From 53c84be49f961fd43fea17d5eca6a18cc1e18a38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Thu, 16 Jan 2020 17:20:34 +0800 Subject: [PATCH 1/2] Added driver for event QueueLength. --- src/async-queue/src/Driver/Driver.php | 2 +- src/async-queue/src/Event/QueueLength.php | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/async-queue/src/Driver/Driver.php b/src/async-queue/src/Driver/Driver.php index 60122d40f..69aa04cb3 100644 --- a/src/async-queue/src/Driver/Driver.php +++ b/src/async-queue/src/Driver/Driver.php @@ -112,7 +112,7 @@ abstract class Driver implements DriverInterface { $info = $this->info(); foreach ($info as $key => $value) { - $this->event && $this->event->dispatch(new QueueLength($key, $value)); + $this->event && $this->event->dispatch(new QueueLength($this, $key, $value)); } } diff --git a/src/async-queue/src/Event/QueueLength.php b/src/async-queue/src/Event/QueueLength.php index d8b52a2a5..cbfddedb6 100644 --- a/src/async-queue/src/Event/QueueLength.php +++ b/src/async-queue/src/Event/QueueLength.php @@ -12,8 +12,16 @@ declare(strict_types=1); namespace Hyperf\AsyncQueue\Event; +use Hyperf\AsyncQueue\Driver\Driver; +use Hyperf\AsyncQueue\Driver\DriverInterface; + class QueueLength { + /** + * @var Driver + */ + public $driver; + /** * @var string */ @@ -24,8 +32,9 @@ class QueueLength */ public $length; - public function __construct(string $key, int $length) + public function __construct(DriverInterface $driver, string $key, int $length) { + $this->driver = $driver; $this->key = $key; $this->length = $length; } From 505abe0fcd213af596b63a00c249507f7be4a66c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Thu, 16 Jan 2020 17:33:48 +0800 Subject: [PATCH 2/2] Update QueueLength.php --- src/async-queue/src/Event/QueueLength.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/async-queue/src/Event/QueueLength.php b/src/async-queue/src/Event/QueueLength.php index cbfddedb6..9b74ea516 100644 --- a/src/async-queue/src/Event/QueueLength.php +++ b/src/async-queue/src/Event/QueueLength.php @@ -12,13 +12,12 @@ declare(strict_types=1); namespace Hyperf\AsyncQueue\Event; -use Hyperf\AsyncQueue\Driver\Driver; use Hyperf\AsyncQueue\Driver\DriverInterface; class QueueLength { /** - * @var Driver + * @var DriverInterface */ public $driver;