Skip to content

Commit 6a84f65

Browse files
committed
multi client configuration
1 parent 3e4d486 commit 6a84f65

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

‎pkg/enqueue/Symfony/Consumption/ConsumeCommand.php‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,20 @@ class ConsumeCommand extends Command
2727
/**
2828
* @var string
2929
*/
30-
private $queueConsumerIdPattern;
30+
private $defaultTransport;
3131

3232
/**
33-
* [name => QueueConsumerInterface].
34-
*
35-
* @param QueueConsumerInterface[]
33+
* @var string
3634
*/
37-
public function __construct(ContainerInterface $container, string $queueConsumerIdPattern = 'enqueue.transport.%s.queue_consumer')
38-
{
39-
parent::__construct(static::$defaultName);
35+
private $queueConsumerIdPattern;
4036

37+
public function __construct(ContainerInterface $container, string $defaultTransport, string $queueConsumerIdPattern = 'enqueue.transport.%s.queue_consumer')
38+
{
4139
$this->container = $container;
40+
$this->defaultTransport = $defaultTransport;
4241
$this->queueConsumerIdPattern = $queueConsumerIdPattern;
42+
43+
parent::__construct(static::$defaultName);
4344
}
4445

4546
protected function configure(): void
@@ -49,7 +50,7 @@ protected function configure(): void
4950
$this->configureLoggerExtension();
5051

5152
$this
52-
->addOption('transport', 't', InputOption::VALUE_OPTIONAL, 'The transport to consume messages from.', 'default')
53+
->addOption('transport', 't', InputOption::VALUE_OPTIONAL, 'The transport to consume messages from.', $this->defaultTransport)
5354
->setDescription('A worker that consumes message from a broker. '.
5455
'To use this broker you have to configure queue consumer before adding to the command')
5556
;

‎pkg/enqueue/Tests/Symfony/Consumption/ConsumeCommandTest.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ public function testShouldNotBeFinal()
2828

2929
public function testCouldBeConstructedWithRequiredAttributes()
3030
{
31-
new ConsumeCommand($this->createMock(ContainerInterface::class));
31+
new ConsumeCommand($this->createMock(ContainerInterface::class), 'default');
3232
}
3333

3434
public function testShouldHaveCommandName()
3535
{
36-
$command = new ConsumeCommand($this->createMock(ContainerInterface::class));
36+
$command = new ConsumeCommand($this->createMock(ContainerInterface::class), 'default');
3737

3838
$this->assertEquals('enqueue:transport:consume', $command->getName());
3939
}
4040

4141
public function testShouldHaveExpectedOptions()
4242
{
43-
$command = new ConsumeCommand($this->createMock(ContainerInterface::class));
43+
$command = new ConsumeCommand($this->createMock(ContainerInterface::class), 'default');
4444

4545
$options = $command->getDefinition()->getOptions();
4646

@@ -56,7 +56,7 @@ public function testShouldHaveExpectedOptions()
5656

5757
public function testShouldHaveExpectedAttributes()
5858
{
59-
$command = new ConsumeCommand($this->createMock(ContainerInterface::class));
59+
$command = new ConsumeCommand($this->createMock(ContainerInterface::class), 'default');
6060

6161
$arguments = $command->getDefinition()->getArguments();
6262

@@ -74,7 +74,7 @@ public function testShouldExecuteDefaultConsumption()
7474

7575
$command = new ConsumeCommand(new Container([
7676
'enqueue.transport.default.queue_consumer' => $consumer,
77-
]));
77+
]), 'default');
7878

7979
$tester = new CommandTester($command);
8080
$tester->execute([]);
@@ -98,7 +98,7 @@ public function testShouldExecuteCustomConsumption()
9898
$command = new ConsumeCommand(new Container([
9999
'enqueue.transport.default.queue_consumer' => $defaultConsumer,
100100
'enqueue.transport.custom.queue_consumer' => $customConsumer,
101-
]));
101+
]), 'default');
102102

103103
$tester = new CommandTester($command);
104104
$tester->execute(['--transport' => 'custom']);
@@ -114,7 +114,7 @@ public function testThrowIfNotDefinedTransportRequested()
114114

115115
$command = new ConsumeCommand(new Container([
116116
'enqueue.transport.default.queue_consumer' => $defaultConsumer,
117-
]));
117+
]), 'default');
118118

119119
$tester = new CommandTester($command);
120120

0 commit comments

Comments
 (0)