Merge pull request #1288 from limingxinleo/1.1-queue

Added driver object into Hyperf\AsyncQueue\Event\QueueLength event as the first parameter
This commit is contained in:
黄朝晖 2020-01-24 13:23:07 +08:00 committed by GitHub
commit 5f43f74541
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -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));
}
}

View File

@ -12,8 +12,15 @@ declare(strict_types=1);
namespace Hyperf\AsyncQueue\Event;
use Hyperf\AsyncQueue\Driver\DriverInterface;
class QueueLength
{
/**
* @var DriverInterface
*/
public $driver;
/**
* @var string
*/
@ -24,8 +31,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;
}