Skip to content

Commit 91abc46

Browse files
committed
remove idle_time.
1 parent 2ec051d commit 91abc46

File tree

15 files changed

+15
-116
lines changed

15 files changed

+15
-116
lines changed

docs/bundle/config_reference.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ enqueue:
3131
redelivered_delay_time: 0
3232
consumption:
3333

34-
# the time in milliseconds queue consumer waits if no message received
35-
idle_timeout: 0
36-
3734
# the time in milliseconds queue consumer waits for a message (100 ms by default)
3835
receive_timeout: 100
3936
job: false

pkg/enqueue-bundle/DependencyInjection/EnqueueExtension.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ public function load(array $configs, ContainerBuilder $container): void
9191
}
9292

9393
$container->getDefinition('enqueue.client.default.queue_consumer')
94-
->replaceArgument(4, $config['consumption']['idle_time'])
95-
->replaceArgument(5, $config['consumption']['receive_timeout'])
94+
->replaceArgument(4, $config['consumption']['receive_timeout'])
9695
;
9796
}
9897

pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public function testShouldUseDefaultConfigurationIfNothingIsConfiguredAtAll()
3939
$this->assertEquals([
4040
'transport' => ['dsn' => 'null:'],
4141
'consumption' => [
42-
'idle_time' => 0,
4342
'receive_timeout' => 10000,
4443
],
4544
'job' => false,
@@ -66,7 +65,6 @@ public function testShouldUseDefaultTransportIfIfTransportIsConfiguredAtAll()
6665
$this->assertEquals([
6766
'transport' => ['dsn' => 'null:'],
6867
'consumption' => [
69-
'idle_time' => 0,
7068
'receive_timeout' => 10000,
7169
],
7270
'job' => false,
@@ -383,7 +381,6 @@ public function testShouldSetDefaultConfigurationForConsumption()
383381

384382
$this->assertArraySubset([
385383
'consumption' => [
386-
'idle_time' => 0,
387384
'receive_timeout' => 10000,
388385
],
389386
], $config);
@@ -397,14 +394,12 @@ public function testShouldAllowConfigureConsumption()
397394
$config = $processor->processConfiguration($configuration, [[
398395
'transport' => [],
399396
'consumption' => [
400-
'idle_time' => 123,
401397
'receive_timeout' => 456,
402398
],
403399
]]);
404400

405401
$this->assertArraySubset([
406402
'consumption' => [
407-
'idle_time' => 123,
408403
'receive_timeout' => 456,
409404
],
410405
], $config);

pkg/enqueue-bundle/Tests/Unit/DependencyInjection/EnqueueExtensionTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -430,21 +430,17 @@ public function testShouldConfigureQueueConsumer()
430430
'transport' => [
431431
],
432432
'consumption' => [
433-
'idle_time' => 123,
434433
'receive_timeout' => 456,
435434
],
436435
]], $container);
437436

438437
$def = $container->getDefinition('enqueue.transport.default.queue_consumer');
439-
$this->assertSame('%enqueue.transport.default.idle_time%', $def->getArgument(4));
440-
$this->assertSame('%enqueue.transport.default.receive_timeout%', $def->getArgument(5));
438+
$this->assertSame('%enqueue.transport.default.receive_timeout%', $def->getArgument(4));
441439

442-
$this->assertSame(123, $container->getParameter('enqueue.transport.default.idle_time'));
443440
$this->assertSame(456, $container->getParameter('enqueue.transport.default.receive_timeout'));
444441

445442
$def = $container->getDefinition('enqueue.client.default.queue_consumer');
446-
$this->assertSame(123, $def->getArgument(4));
447-
$this->assertSame(456, $def->getArgument(5));
443+
$this->assertSame(456, $def->getArgument(4));
448444
}
449445

450446
public function testShouldLoadProcessAutoconfigureChildDefinition()

pkg/enqueue/Consumption/Context/Start.php

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ final class Start
2828
*/
2929
private $receiveTimeout;
3030

31-
/**
32-
* @var int
33-
*/
34-
private $idleTime;
35-
3631
/**
3732
* @var int
3833
*/
@@ -46,13 +41,12 @@ final class Start
4641
/**
4742
* @param BoundProcessor[] $processors
4843
*/
49-
public function __construct(Context $context, LoggerInterface $logger, array $processors, int $receiveTimeout, int $idleTime, int $startTime)
44+
public function __construct(Context $context, LoggerInterface $logger, array $processors, int $receiveTimeout, int $startTime)
5045
{
5146
$this->context = $context;
5247
$this->logger = $logger;
5348
$this->processors = $processors;
5449
$this->receiveTimeout = $receiveTimeout;
55-
$this->idleTime = $idleTime;
5650
$this->startTime = $startTime;
5751

5852
$this->executionInterrupted = false;
@@ -89,22 +83,6 @@ public function changeReceiveTimeout(int $timeout): void
8983
$this->receiveTimeout = $timeout;
9084
}
9185

92-
/**
93-
* In milliseconds.
94-
*/
95-
public function getIdleTime(): int
96-
{
97-
return $this->idleTime;
98-
}
99-
100-
/**
101-
* In milliseconds.
102-
*/
103-
public function changeIdleTime(int $time): void
104-
{
105-
$this->idleTime = $time;
106-
}
107-
10886
/**
10987
* In milliseconds.
11088
*/

pkg/enqueue/Consumption/QueueConsumer.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ final class QueueConsumer implements QueueConsumerInterface
4040
*/
4141
private $boundProcessors;
4242

43-
/**
44-
* @var int|float in milliseconds
45-
*/
46-
private $idleTime;
47-
4843
/**
4944
* @var int|float in milliseconds
5045
*/
@@ -67,19 +62,16 @@ final class QueueConsumer implements QueueConsumerInterface
6762

6863
/**
6964
* @param BoundProcessor[] $boundProcessors
70-
* @param int|float $idleTime the time in milliseconds queue consumer waits if no message received
7165
* @param int|float $receiveTimeout the time in milliseconds queue consumer waits for a message (10 ms by default)
7266
*/
7367
public function __construct(
7468
InteropContext $interopContext,
7569
ExtensionInterface $extension = null,
7670
array $boundProcessors = [],
7771
LoggerInterface $logger = null,
78-
int $idleTime = 0,
7972
int $receiveTimeout = 10000
8073
) {
8174
$this->interopContext = $interopContext;
82-
$this->idleTime = $idleTime;
8375
$this->receiveTimeout = $receiveTimeout;
8476

8577
$this->staticExtension = $extension ?: new ChainExtension([]);
@@ -93,16 +85,6 @@ public function __construct(
9385
$this->fallbackSubscriptionConsumer = new FallbackSubscriptionConsumer();
9486
}
9587

96-
public function setIdleTime(int $time): void
97-
{
98-
$this->idleTime = $time;
99-
}
100-
101-
public function getIdleTime(): int
102-
{
103-
return $this->idleTime;
104-
}
105-
10688
public function setReceiveTimeout(int $timeout): void
10789
{
10890
$this->receiveTimeout = $timeout;
@@ -169,7 +151,6 @@ public function consume(ExtensionInterface $runtimeExtension = null): void
169151
$this->logger,
170152
$this->boundProcessors,
171153
$this->receiveTimeout,
172-
$this->idleTime,
173154
$startTime
174155
);
175156

@@ -180,7 +161,6 @@ public function consume(ExtensionInterface $runtimeExtension = null): void
180161
}
181162

182163
$this->logger = $start->getLogger();
183-
$this->idleTime = $start->getIdleTime();
184164
$this->receiveTimeout = $start->getReceiveTimeout();
185165
$this->boundProcessors = $start->getBoundProcessors();
186166

@@ -320,7 +300,6 @@ public function consume(ExtensionInterface $runtimeExtension = null): void
320300

321301
$subscriptionConsumer->consume($this->receiveTimeout);
322302

323-
$this->idleTime && usleep($this->idleTime * 1000);
324303
$this->extension->onIdle($context);
325304

326305
if ($context->isExecutionInterrupted()) {

pkg/enqueue/Consumption/QueueConsumerInterface.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@
88

99
interface QueueConsumerInterface
1010
{
11-
/**
12-
* In milliseconds.
13-
*/
14-
public function setIdleTime(int $time): void;
15-
16-
/**
17-
* In milliseconds.
18-
*/
19-
public function getIdleTime(): int;
20-
2111
/**
2212
* In milliseconds.
2313
*/

pkg/enqueue/Symfony/Consumption/QueueConsumerOptionsCommandTrait.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ trait QueueConsumerOptionsCommandTrait
1414
protected function configureQueueConsumerOptions()
1515
{
1616
$this
17-
->addOption('idle-time', null, InputOption::VALUE_REQUIRED, 'The time in milliseconds queue consumer idle if no message has been received.')
1817
->addOption('receive-timeout', null, InputOption::VALUE_REQUIRED, 'The time in milliseconds queue consumer waits for a message.')
1918
;
2019
}
@@ -25,10 +24,6 @@ protected function configureQueueConsumerOptions()
2524
*/
2625
protected function setQueueConsumerOptions(QueueConsumerInterface $consumer, InputInterface $input)
2726
{
28-
if (null !== $idleTimeout = $input->getOption('idle-time')) {
29-
$consumer->setIdleTime((int) $idleTimeout);
30-
}
31-
3227
if (null !== $receiveTimeout = $input->getOption('receive-timeout')) {
3328
$consumer->setReceiveTimeout((int) $receiveTimeout);
3429
}

pkg/enqueue/Symfony/DependencyInjection/TransportFactory.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ public function addQueueConsumerConfiguration(ArrayNodeDefinition $builder): voi
9898
{
9999
$builder
100100
->addDefaultsIfNotSet()->children()
101-
->integerNode('idle_time')
102-
->min(0)
103-
->defaultValue(0)
104-
->info('the time in milliseconds queue consumer waits if no message received')
105-
->end()
106101
->integerNode('receive_timeout')
107102
->min(0)
108103
->defaultValue(10000)
@@ -169,7 +164,6 @@ public function buildQueueConsumer(ContainerBuilder $container, array $config):
169164
$contextId = $this->format('context');
170165
$this->assertServiceExists($container, $contextId);
171166

172-
$container->setParameter($this->format('idle_time'), $config['idle_time'] ?? 0);
173167
$container->setParameter($this->format('receive_timeout'), $config['receive_timeout'] ?? 10000);
174168

175169
$container->register($this->format('consumption_extensions'), ChainExtension::class)
@@ -181,7 +175,6 @@ public function buildQueueConsumer(ContainerBuilder $container, array $config):
181175
->addArgument(new Reference($this->format('consumption_extensions')))
182176
->addArgument([])
183177
->addArgument(null)
184-
->addArgument($this->format('idle_time', true))
185178
->addArgument($this->format('receive_timeout', true))
186179
;
187180

pkg/enqueue/Tests/Consumption/QueueConsumerTest.php

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class QueueConsumerTest extends TestCase
3535
{
3636
public function testCouldBeConstructedWithAllArguments()
3737
{
38-
new QueueConsumer($this->createContextStub(), null, [], null, 0, 0);
38+
new QueueConsumer($this->createContextStub(), null, [], null, 0);
3939
}
4040

4141
public function testCouldBeConstructedWithContextOnly()
@@ -50,7 +50,7 @@ public function testCouldBeConstructedWithContextAndSingleExtension()
5050

5151
public function testShouldSetEmptyArrayToBoundProcessorsPropertyInConstructor()
5252
{
53-
$consumer = new QueueConsumer($this->createContextStub(), null, [], null, 0, 0);
53+
$consumer = new QueueConsumer($this->createContextStub(), null, [], null, 0);
5454

5555
$this->assertAttributeSame([], 'boundProcessors', $consumer);
5656
}
@@ -62,14 +62,14 @@ public function testShouldSetProvidedBoundProcessorsToThePropertyInConstructor()
6262
new BoundProcessor(new NullQueue('bar'), $this->createProcessorMock()),
6363
];
6464

65-
$consumer = new QueueConsumer($this->createContextStub(), null, $boundProcessors, null, 0, 0);
65+
$consumer = new QueueConsumer($this->createContextStub(), null, $boundProcessors, null, 0);
6666

6767
$this->assertAttributeSame($boundProcessors, 'boundProcessors', $consumer);
6868
}
6969

7070
public function testShouldSetNullLoggerIfNoneProvidedInConstructor()
7171
{
72-
$consumer = new QueueConsumer($this->createContextStub(), null, [], null, 0, 0);
72+
$consumer = new QueueConsumer($this->createContextStub(), null, [], null, 0);
7373

7474
$this->assertAttributeInstanceOf(NullLogger::class, 'logger', $consumer);
7575
}
@@ -78,7 +78,7 @@ public function testShouldSetProvidedLoggerToThePropertyInConstructor()
7878
{
7979
$expectedLogger = $this->createMock(LoggerInterface::class);
8080

81-
$consumer = new QueueConsumer($this->createContextStub(), null, [], $expectedLogger, 0, 0);
81+
$consumer = new QueueConsumer($this->createContextStub(), null, [], $expectedLogger, 0);
8282

8383
$this->assertAttributeSame($expectedLogger, 'logger', $consumer);
8484
}
@@ -87,7 +87,7 @@ public function testShouldAllowGetContextSetInConstructor()
8787
{
8888
$expectedContext = $this->createContextStub();
8989

90-
$consumer = new QueueConsumer($expectedContext, null, [], null, 0, 0);
90+
$consumer = new QueueConsumer($expectedContext, null, [], null, 0);
9191

9292
$this->assertSame($expectedContext, $consumer->getContext());
9393
}
@@ -143,15 +143,6 @@ public function testThrowIfQueueNeitherInstanceOfQueueNorString()
143143
$consumer->bind(new \stdClass(), $processorMock);
144144
}
145145

146-
public function testCouldSetGetIdleTime()
147-
{
148-
$consumer = new QueueConsumer($this->createContextStub());
149-
150-
$consumer->setIdleTime(123456);
151-
152-
$this->assertSame(123456, $consumer->getIdleTime());
153-
}
154-
155146
public function testCouldSetGetReceiveTimeout()
156147
{
157148
$consumer = new QueueConsumer($this->createContextStub());
@@ -311,7 +302,7 @@ public function testShouldSubscribeToGivenQueueWithExpectedTimeout()
311302
->method('process')
312303
;
313304

314-
$queueConsumer = new QueueConsumer($contextMock, new BreakCycleExtension(1), [], null, 0, 12345);
305+
$queueConsumer = new QueueConsumer($contextMock, new BreakCycleExtension(1), [], null, 12345);
315306
$queueConsumer->setFallbackSubscriptionConsumer($subscriptionConsumerMock);
316307
$queueConsumer->bind($expectedQueue, $processorMock);
317308
$queueConsumer->consume();

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,10 @@ public function testShouldHaveExpectedOptions()
5050

5151
$options = $command->getDefinition()->getOptions();
5252

53-
$this->assertCount(10, $options);
53+
$this->assertCount(9, $options);
5454
$this->assertArrayHasKey('memory-limit', $options);
5555
$this->assertArrayHasKey('message-limit', $options);
5656
$this->assertArrayHasKey('time-limit', $options);
57-
$this->assertArrayHasKey('idle-time', $options);
5857
$this->assertArrayHasKey('receive-timeout', $options);
5958
$this->assertArrayHasKey('niceness', $options);
6059
$this->assertArrayHasKey('client', $options);

pkg/enqueue/Tests/Symfony/Consumption/ConfigurableConsumeCommandTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,10 @@ public function testShouldHaveExpectedOptions()
5050

5151
$options = $command->getDefinition()->getOptions();
5252

53-
$this->assertCount(8, $options);
53+
$this->assertCount(7, $options);
5454
$this->assertArrayHasKey('memory-limit', $options);
5555
$this->assertArrayHasKey('message-limit', $options);
5656
$this->assertArrayHasKey('time-limit', $options);
57-
$this->assertArrayHasKey('idle-time', $options);
5857
$this->assertArrayHasKey('receive-timeout', $options);
5958
$this->assertArrayHasKey('niceness', $options);
6059
$this->assertArrayHasKey('transport', $options);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@ public function testShouldHaveExpectedOptions()
4444

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

47-
$this->assertCount(8, $options);
47+
$this->assertCount(7, $options);
4848
$this->assertArrayHasKey('memory-limit', $options);
4949
$this->assertArrayHasKey('message-limit', $options);
5050
$this->assertArrayHasKey('time-limit', $options);
51-
$this->assertArrayHasKey('idle-time', $options);
5251
$this->assertArrayHasKey('receive-timeout', $options);
5352
$this->assertArrayHasKey('niceness', $options);
5453
$this->assertArrayHasKey('transport', $options);

0 commit comments

Comments
 (0)