Skip to content

Commit ffa585e

Browse files
committed
Merge branch 'master' into 0.8
2 parents d401385 + aa0de75 commit ffa585e

File tree

3 files changed

+78
-3
lines changed

3 files changed

+78
-3
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## [0.7.18](https://github.com/php-enqueue/enqueue-dev/tree/0.7.18) (2017-10-10)
4+
[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.7.17...0.7.18)
5+
6+
- \[consumption\]\[client\] Add --skip option to consume commands. [\#216](https://github.com/php-enqueue/enqueue-dev/issues/216)
7+
- \[json\] jsonSerialize could throw an a exception. [\#132](https://github.com/php-enqueue/enqueue-dev/issues/132)
8+
- \[client\] Add --skip option to consume command. [\#218](https://github.com/php-enqueue/enqueue-dev/pull/218) ([makasim](https://github.com/makasim))
9+
310
## [0.7.17](https://github.com/php-enqueue/enqueue-dev/tree/0.7.17) (2017-10-03)
411
[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.7.16...0.7.17)
512

pkg/enqueue/Symfony/Client/ConsumeMessagesCommand.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Enqueue\Client\DelegateProcessor;
66
use Enqueue\Client\DriverInterface;
7+
use Enqueue\Client\Meta\QueueMeta;
78
use Enqueue\Client\Meta\QueueMetaRegistry;
89
use Enqueue\Consumption\ChainExtension;
910
use Enqueue\Consumption\Extension\LoggerExtension;
@@ -13,6 +14,7 @@
1314
use Symfony\Component\Console\Command\Command;
1415
use Symfony\Component\Console\Input\InputArgument;
1516
use Symfony\Component\Console\Input\InputInterface;
17+
use Symfony\Component\Console\Input\InputOption;
1618
use Symfony\Component\Console\Logger\ConsoleLogger;
1719
use Symfony\Component\Console\Output\OutputInterface;
1820

@@ -78,6 +80,7 @@ protected function configure()
7880
'By default it connects to default queue. '.
7981
'It select an appropriate message processor based on a message headers')
8082
->addArgument('client-queue-names', InputArgument::IS_ARRAY, 'Queues to consume messages from')
83+
->addOption('skip', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Queues to skip consumption of messages from', [])
8184
;
8285
}
8386

@@ -94,7 +97,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
9497
$queueMetas[] = $this->queueMetaRegistry->getQueueMeta($clientQueueName);
9598
}
9699
} else {
97-
$queueMetas = $this->queueMetaRegistry->getQueuesMeta();
100+
/** @var QueueMeta[] $queueMetas */
101+
$queueMetas = iterator_to_array($this->queueMetaRegistry->getQueuesMeta());
102+
103+
foreach ($queueMetas as $index => $queueMeta) {
104+
if (in_array($queueMeta->getClientName(), $input->getOption('skip'), true)) {
105+
unset($queueMetas[$index]);
106+
}
107+
}
98108
}
99109

100110
foreach ($queueMetas as $queueMeta) {

pkg/enqueue/Tests/Symfony/Client/ConsumeMessagesCommandTest.php

+60-2
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,17 @@ public function testShouldHaveExpectedOptions()
6161

6262
$options = $command->getDefinition()->getOptions();
6363

64-
$this->assertCount(6, $options);
64+
$this->assertCount(7, $options);
6565
$this->assertArrayHasKey('memory-limit', $options);
6666
$this->assertArrayHasKey('message-limit', $options);
6767
$this->assertArrayHasKey('time-limit', $options);
6868
$this->assertArrayHasKey('setup-broker', $options);
6969
$this->assertArrayHasKey('idle-timeout', $options);
7070
$this->assertArrayHasKey('receive-timeout', $options);
71+
$this->assertArrayHasKey('skip', $options);
7172
}
7273

73-
public function testShouldHaveExpectedAttributes()
74+
public function testShouldHaveExpectedArguments()
7475
{
7576
$command = new ConsumeMessagesCommand(
7677
$this->createQueueConsumerMock(),
@@ -171,6 +172,63 @@ public function testShouldExecuteConsumptionAndUseCustomClientDestinationName()
171172
]);
172173
}
173174

175+
public function testShouldSkipQueueConsumptionAndUseCustomClientDestinationName()
176+
{
177+
$queue = new NullQueue('');
178+
179+
$processor = $this->createDelegateProcessorMock();
180+
181+
$context = $this->createPsrContextMock();
182+
$context
183+
->expects($this->never())
184+
->method('close')
185+
;
186+
187+
$consumer = $this->createQueueConsumerMock();
188+
$consumer
189+
->expects($this->exactly(2))
190+
->method('bind')
191+
;
192+
$consumer
193+
->expects($this->once())
194+
->method('consume')
195+
->with($this->isInstanceOf(ChainExtension::class))
196+
;
197+
198+
$queueMetaRegistry = $this->createQueueMetaRegistry([
199+
'fooQueue' => [
200+
'transportName' => 'fooTransportQueue',
201+
],
202+
'barQueue' => [
203+
'transportName' => 'barTransportQueue',
204+
],
205+
'ololoQueue' => [
206+
'transportName' => 'ololoTransportQueue',
207+
],
208+
]);
209+
210+
$driver = $this->createDriverMock();
211+
$driver
212+
->expects($this->at(0))
213+
->method('createQueue')
214+
->with('fooQueue')
215+
->willReturn($queue)
216+
;
217+
$driver
218+
->expects($this->at(1))
219+
->method('createQueue')
220+
->with('ololoQueue')
221+
->willReturn($queue)
222+
;
223+
224+
$command = new ConsumeMessagesCommand($consumer, $processor, $queueMetaRegistry, $driver);
225+
226+
$tester = new CommandTester($command);
227+
$tester->execute([
228+
'--skip' => ['barQueue'],
229+
]);
230+
}
231+
174232
/**
175233
* @param array $destinationNames
176234
*

0 commit comments

Comments
 (0)