8000 Parameterize historySize · symfony/symfony@b98038c · GitHub
[go: up one dir, main page]

Skip to content

Commit b98038c

Browse files
committed
Parameterize historySize
1 parent 8a929c5 commit b98038c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Symfony/Component/Messenger/EventListener/SendFailedMessageForRetryListener.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@
2929
*/
3030
class SendFailedMessageForRetryListener implements EventSubscriberInterface
3131
{
32-
private const HISTORY_SIZE = 10;
33-
3432
private $sendersLocator;
3533
private $retryStrategyLocator;
3634
private $logger;
35+
private $historySize;
3736

38-
public function __construct(ContainerInterface $sendersLocator, ContainerInterface $retryStrategyLocator, LoggerInterface $logger = null)
37+
public function __construct(ContainerInterface $sendersLocator, ContainerInterface $retryStrategyLocator, LoggerInterface $logger = null, int $historySize = 10)
3938
{
4039
$this->sendersLocator = $sendersLocator;
4140
$this->retryStrategyLocator = $retryStrategyLocator;
4241
$this->logger = $logger;
42+
$this->historySize = $historySize;
4343
}
4444

4545
public function onMessageFailed(WorkerMessageFailedEvent $event)
@@ -85,14 +85,14 @@ private function withLimitedHistory(Envelope $envelope, StampInterface ...$stamp
8585
{
8686
foreach ($stamps as $stamp) {
8787
$history = $envelope->all(get_class($stamp));
88-
if (\count($history) < self::HISTORY_SIZE) {
88+
if (\count($history) < $this->historySize) {
8989
$envelope = $envelope->with($stamp);
9090
continue;
9191
}
9292

9393
$history = \array_merge(
9494
[$history[0]],
95-
\array_slice($history, -self::HISTORY_SIZE + 2),
95+
\array_slice($history, -$this->historySize + 2),
9696
[$stamp]
9797
);
9898

src/Symfony/Component/Messenger/Tests/EventListener/SendFailedMessageForRetryListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function testEnvelopeKeepOnlyTheLast10Stamps()
8282
$exception = new \Exception('no!');
8383
$stamps = \array_merge(
8484
\array_fill(0, 15, new DelayStamp(1)),
85-
\array_fill(0, 3, new RedeliveryStamp(1)),
85+
\array_fill(0, 3, new RedeliveryStamp(1))
8686
);
8787
$envelope = new Envelope(new \stdClass(), $stamps);
8888

0 commit comments

Comments
 (0)
0