Skip to content

Commit aab0415

Browse files
authored
refactor(async-queue): rename $queue property to $pool in ConsumerProcess (#7615)
1 parent b473a22 commit aab0415

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/Process/ConsumerProcess.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414

1515
use Hyperf\AsyncQueue\Driver\DriverFactory;
1616
use Hyperf\AsyncQueue\Driver\DriverInterface;
17+
use Hyperf\Contract\StdoutLoggerInterface;
1718
use Hyperf\Process\AbstractProcess;
1819
use Psr\Container\ContainerInterface;
1920

2021
class ConsumerProcess extends AbstractProcess
2122
{
22-
protected string $queue = 'default';
23+
protected string $pool = 'default';
2324

2425
protected DriverInterface $driver;
2526

@@ -29,11 +30,19 @@ public function __construct(ContainerInterface $container)
2930
{
3031
parent::__construct($container);
3132

33+
// compatible with older versions, will be removed in v3.2, use `$pool` instead.
34+
if (property_exists($this, 'queue')) {
35+
if ($container->has(StdoutLoggerInterface::class)) {
36+
$container->get(StdoutLoggerInterface::class)->warning(sprintf('The property "%s::$queue" is deprecated since v3.1 and will be removed in v3.2, use "%s::$pool" instead.', self::class, self::class));
37+
}
38+
$this->pool = $this->queue;
39+
}
40+
3241
$factory = $this->container->get(DriverFactory::class);
33-
$this->driver = $factory->get($this->queue);
34-
$this->config = $factory->getConfig($this->queue);
42+
$this->driver = $factory->get($this->pool);
43+
$this->config = $factory->getConfig($this->pool);
3544

36-
$this->name = "queue.{$this->queue}";
45+
$this->name = "queue.{$this->pool}";
3746
$this->nums = $this->config['processes'] ?? 1;
3847
}
3948

0 commit comments

Comments
 (0)