Skip to content

Commit 88a3cee

Browse files
committed
fix: Fix wrong sentence and add type on new receiver
1 parent 66d5e93 commit 88a3cee

3 files changed

Lines changed: 21 additions & 19 deletions

File tree

src/Console/Command/ConsumeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function configure(): void
8383
->addOption('save', null, InputOption::VALUE_NONE, 'Save failed job.')
8484
->addOption('max', null, InputOption::VALUE_REQUIRED, 'The max number of jobs.')
8585
->addOption('expire', null, InputOption::VALUE_REQUIRED, 'The worker duration in seconds.')
86-
->addOption('expireWhenEmpty', null, InputOption::VALUE_REQUIRED, 'Stop the worker when the queues are empty for a among of time in seconds.')
86+
->addOption('expireWhenEmpty', null, InputOption::VALUE_REQUIRED, 'Stop the worker when the queues are empty for an among of time in seconds.')
8787
->addOption('stopWhenEmpty', null, InputOption::VALUE_NONE, 'Stop the worker if the queues are empty.')
8888
->addOption('stopOnError', null, InputOption::VALUE_NONE, 'Stop the worker if error occurs.')
8989
->addOption('logger', null, InputOption::VALUE_REQUIRED, 'The logger to use "stdout", "null", or "default".', "default")

src/Consumer/Receiver/LimitTimeWhenEmptyReceiver.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,9 @@ class LimitTimeWhenEmptyReceiver implements ReceiverInterface
1414
{
1515
use DelegateHelper;
1616

17-
/**
18-
* Time limit in second
19-
*
20-
* @var int
21-
*/
22-
private $limit;
23-
24-
/**
25-
* The end time
26-
*
27-
* @var int
28-
*/
29-
private $endTime;
30-
31-
/**
32-
* @var LoggerInterface
33-
*/
34-
private $logger;
17+
private int $limit;
18+
private ?int $endTime;
19+
private ?LoggerInterface $logger;
3520

3621
/**
3722
* TimeLimiterMiddlewareReceiver constructor.

tests/Consumer/Receiver/Builder/ReceiverBuilderTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Bdf\Queue\Consumer\Receiver\BenchReceiver;
1010
use Bdf\Queue\Consumer\Receiver\Binder\BinderReceiver;
1111
use Bdf\Queue\Consumer\Receiver\Binder\ClassNameBinder;
12+
use Bdf\Queue\Consumer\Receiver\LimitTimeWhenEmptyReceiver;
1213
use Bdf\Queue\Consumer\Receiver\MemoryLimiterReceiver;
1314
use Bdf\Queue\Consumer\Receiver\MessageCountLimiterReceiver;
1415
use Bdf\Queue\Consumer\Receiver\MessageLoggerReceiver;
@@ -573,6 +574,22 @@ public function test_expire()
573574
);
574575
}
575576

577+
/**
578+
*
579+
*/
580+
public function test_expire_when_empty()
581+
{
582+
$this->builder->expireWhenEmpty(10);
583+
584+
$this->assertEquals(
585+
new ReceiverPipeline([
586+
new LimitTimeWhenEmptyReceiver(10, new LoggerProxy(new NullLogger())),
587+
new ProcessorReceiver(new JobHintProcessorResolver($this->container->get(InstantiatorInterface::class))),
588+
]),
589+
$this->builder->build()
590+
);
591+
}
592+
576593
/**
577594
*
578595
*/

0 commit comments

Comments
 (0)