Skip to content

Commit 9625a93

Browse files
committed
Fixed proxy class repeat instantiation.
1 parent f7f4995 commit 9625a93

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

src/Command/FlushFailedMessageCommand.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use Hyperf\AsyncQueue\Driver\DriverFactory;
1616
use Hyperf\Framework\Annotation\Command;
17+
use Psr\Container\ContainerInterface;
1718
use Symfony\Component\Console\Command\Command as SymfonyCommand;
1819
use Symfony\Component\Console\Input\InputArgument;
1920
use Symfony\Component\Console\Input\InputInterface;
@@ -25,21 +26,21 @@
2526
class FlushFailedMessageCommand extends SymfonyCommand
2627
{
2728
/**
28-
* @var DriverFactory
29+
* @var ContainerInterface
2930
*/
30-
protected $factory;
31+
protected $container;
3132

32-
public function __construct(DriverFactory $factory)
33+
public function __construct(ContainerInterface $container)
3334
{
34-
$this->factory = $factory;
35+
$this->container = $container;
3536
parent::__construct('queue:flush');
3637
}
3738

3839
public function execute(InputInterface $input, OutputInterface $output)
3940
{
4041
$name = $input->getArgument('name');
41-
42-
$driver = $this->factory->get($name);
42+
$factory = $this->container->get(DriverFactory::class);
43+
$driver = $factory->get($name);
4344

4445
$driver->flush();
4546

src/Command/InfoCommand.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use Hyperf\AsyncQueue\Driver\DriverFactory;
1616
use Hyperf\Framework\Annotation\Command;
17+
use Psr\Container\ContainerInterface;
1718
use Symfony\Component\Console\Command\Command as SymfonyCommand;
1819
use Symfony\Component\Console\Input\InputArgument;
1920
use Symfony\Component\Console\Input\InputInterface;
@@ -25,21 +26,21 @@
2526
class InfoCommand extends SymfonyCommand
2627
{
2728
/**
28-
* @var DriverFactory
29+
* @var ContainerInterface
2930
*/
30-
protected $factory;
31+
protected $container;
3132

32-
public function __construct(DriverFactory $factory)
33+
public function __construct(ContainerInterface $container)
3334
{
34-
$this->factory = $factory;
35+
$this->container = $container;
3536
parent::__construct('queue:info');
3637
}
3738

3839
public function execute(InputInterface $input, OutputInterface $output)
3940
{
4041
$name = $input->getArgument('name');
41-
42-
$driver = $this->factory->get($name);
42+
$factory = $this->container->get(DriverFactory::class);
43+
$driver = $factory->get($name);
4344

4445
$info = $driver->info();
4546
foreach ($info as $key => $count) {

src/Command/ReloadFailedMessageCommand.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use Hyperf\AsyncQueue\Driver\DriverFactory;
1616
use Hyperf\Framework\Annotation\Command;
17+
use Psr\Container\ContainerInterface;
1718
use Symfony\Component\Console\Command\Command as SymfonyCommand;
1819
use Symfony\Component\Console\Input\InputArgument;
1920
use Symfony\Component\Console\Input\InputInterface;
@@ -25,21 +26,21 @@
2526
class ReloadFailedMessageCommand extends SymfonyCommand
2627
{
2728
/**
28-
* @var DriverFactory
29+
* @var ContainerInterface
2930
*/
30-
protected $factory;
31+
protected $container;
3132

32-
public function __construct(DriverFactory $factory)
33+
public function __construct(ContainerInterface $container)
3334
{
35+
$this->container = $container;
3436
parent::__construct('queue:reload');
35-
$this->factory = $factory;
3637
}
3738

3839
public function execute(InputInterface $input, OutputInterface $output)
3940
{
4041
$name = $input->getArgument('name');
41-
42-
$driver = $this->factory->get($name);
42+
$factory = $this->container->get(DriverFactory::class);
43+
$driver = $factory->get($name);
4344

4445
$num = $driver->reload();
4546

0 commit comments

Comments
 (0)