Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit50c9c8a

Browse files
committed
[Messenger] fix wrong use of generator returns
And some other minor cleanups
1 parentb82b09e commit50c9c8a

File tree

11 files changed

+32
-23
lines changed

11 files changed

+32
-23
lines changed

‎src/Symfony/Component/Messenger/Stamp/SentToFailureTransportStamp.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(string $exceptionMessage, string $originalReceiverNa
3232
$this->exceptionMessage =$exceptionMessage;
3333
$this->originalReceiverName =$originalReceiverName;
3434
$this->flattenException =$flattenException;
35-
$this->sentAt =new \DateTime();
35+
$this->sentAt =new \DateTimeImmutable();
3636
}
3737

3838
publicfunctiongetExceptionMessage():string
@@ -50,7 +50,7 @@ public function getFlattenException(): ?FlattenException
5050
return$this->flattenException;
5151
}
5252

53-
publicfunctiongetSentAt():\DateTime
53+
publicfunctiongetSentAt():\DateTimeInterface
5454
{
5555
return$this->sentAt;
5656
}

‎src/Symfony/Component/Messenger/Tests/Stamp/SentToFailureTransportStampTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ public function testGetters()
2828
$this->assertSame('exception message',$stamp->getExceptionMessage());
2929
$this->assertSame('original_receiver',$stamp->getOriginalReceiverName());
3030
$this->assertSame($flattenException,$stamp->getFlattenException());
31-
$this->assertInstanceOf(\DateTime::class,$stamp->getSentAt());
31+
$this->assertInstanceOf(\DateTimeInterface::class,$stamp->getSentAt());
3232
}
3333
}

‎src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpReceiver.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private function getEnvelope(string $queueName): iterable
5757
}
5858

5959
if (null ===$amqpEnvelope) {
60-
return [];
60+
return;
6161
}
6262

6363
try {

‎src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpTransport.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ public function getMessageCount(): int
8484
return ($this->receiver ??$this->getReceiver())->getMessageCount();
8585
}
8686

87-
privatefunctiongetReceiver()
87+
privatefunctiongetReceiver():AmqpReceiver
8888
{
8989
return$this->receiver =newAmqpReceiver($this->connection,$this->serializer);
9090
}
9191

92-
privatefunctiongetSender()
92+
privatefunctiongetSender():AmqpSender
9393
{
9494
return$this->sender =newAmqpSender($this->connection,$this->serializer);
9595
}

‎src/Symfony/Component/Messenger/Transport/Doctrine/DoctrineReceiver.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function get(): iterable
5454
return [];
5555
}
5656

57-
yield$this->createEnvelopeFromData($doctrineEnvelope);
57+
return [$this->createEnvelopeFromData($doctrineEnvelope)];
5858
}
5959

6060
/**

‎src/Symfony/Component/Messenger/Transport/Receiver/ListableReceiverInterface.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespaceSymfony\Component\Messenger\Transport\Receiver;
413

514
useSymfony\Component\Messenger\Envelope;

‎src/Symfony/Component/Messenger/Transport/Receiver/SingleMessageReceiver.php‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespaceSymfony\Component\Messenger\Transport\Receiver;
413

514
useSymfony\Component\Messenger\Envelope;
@@ -32,7 +41,7 @@ public function get(): iterable
3241

3342
$this->hasReceived =true;
3443

35-
yield$this->envelope;
44+
return [$this->envelope];
3645
}
3746

3847
publicfunctionack(Envelope$envelope):void

‎src/Symfony/Component/Messenger/Transport/RedisExt/RedisReceiver.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function get(): iterable
5757
throw$exception;
5858
}
5959

60-
yield$envelope->with(newRedisReceivedStamp($redisEnvelope['id']));
60+
return [$envelope->with(newRedisReceivedStamp($redisEnvelope['id']))];
6161
}
6262

6363
/**

‎src/Symfony/Component/Messenger/Transport/RedisExt/RedisTransport.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ public function setup(): void
7676
$this->connection->setup();
7777
}
7878

79-
privatefunctiongetReceiver()
79+
privatefunctiongetReceiver():RedisReceiver
8080
{
8181
return$this->receiver =newRedisReceiver($this->connection,$this->serializer);
8282
}
8383

84-
privatefunctiongetSender()
84+
privatefunctiongetSender():RedisSender
8585
{
8686
return$this->sender =newRedisSender($this->connection,$this->serializer);
8787
}

‎src/Symfony/Component/Messenger/Worker.php‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,11 @@ private function handleMessage(Envelope $envelope, ReceiverInterface $receiver,
136136
$envelope =$throwable->getEnvelope();
137137
}
138138

139-
$shouldRetry =$this->shouldRetry($throwable,$envelope,$retryStrategy);
139+
$shouldRetry =$retryStrategy &&$this->shouldRetry($throwable,$envelope,$retryStrategy);
140140

141141
$this->dispatchEvent(newWorkerMessageFailedEvent($envelope,$transportName,$throwable,$shouldRetry));
142142

143143
if ($shouldRetry) {
144-
if (null ===$retryStrategy) {
145-
// not logically allowed, but check just in case
146-
thrownewLogicException('Retrying is not supported without a retry strategy.');
147-
}
148-
149144
$retryCount =$this->getRetryCount($envelope) +1;
150145
if (null !==$this->logger) {
151146
$this->logger->error('Retrying {class} - retry #{retryCount}.',$context + ['retryCount' =>$retryCount,'error' =>$throwable]);
@@ -194,16 +189,12 @@ private function dispatchEvent($event)
194189
$this->eventDispatcher->dispatch($event);
195190
}
196191

197-
privatefunctionshouldRetry(\Throwable$e,Envelope$envelope,?RetryStrategyInterface$retryStrategy):bool
192+
privatefunctionshouldRetry(\Throwable$e,Envelope$envelope,RetryStrategyInterface$retryStrategy):bool
198193
{
199194
if ($einstanceof UnrecoverableMessageHandlingException) {
200195
returnfalse;
201196
}
202197

203-
if (null ===$retryStrategy) {
204-
returnfalse;
205-
}
206-
207198
$sentStamp =$envelope->last(SentStamp::class);
208199
if (null ===$sentStamp) {
209200
if (null !==$this->logger) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp