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

Appearance settings

Commit 88594f9

Browse filesBrowse files
committed
Move "hidden defaults" to constants
1 parent 80fed8f commit 88594f9
Copy full SHA for 88594f9

File tree

2 files changed

+8
-3
lines changed
Filter options

2 files changed

+8
-3
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpReceiver.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
class AmqpReceiver implements ReceiverInterface
2525
{
26+
private const DEFAULT_LOOP_SLEEP_IN_MICRO_SECONDS = 200000;
27+
2628
private $decoder;
2729
private $connection;
2830
private $logger;
@@ -46,7 +48,7 @@ public function receive(callable $handler): void
4648
if (null === $AMQPEnvelope) {
4749
$handler(null);
4850

49-
usleep($this->connection->getConnectionConfiguration()['loop_sleep'] ?? 200000);
51+
usleep($this->connection->getConnectionConfiguration()['loop_sleep'] ?? self::DEFAULT_LOOP_SLEEP_IN_MICRO_SECONDS);
5052
if (\function_exists('pcntl_signal_dispatch')) {
5153
pcntl_signal_dispatch();
5254
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
*/
1919
class Connection
2020
{
21+
private const DEFAULT_MESSAGE_TTL_IN_MILLI_SECONDS = 10000;
22+
private const DEFAULT_MAX_ATTEMPTS = 3;
23+
2124
private $connectionConfiguration;
2225
private $exchangeConfiguration;
2326
private $queueConfiguration;
@@ -158,7 +161,7 @@ public function publishForRetry(\AMQPEnvelope $message): bool
158161
$this->setupRetry($retryConfiguration, $attemptNumber);
159162
}
160163

161-
$maximumAttempts = $retryConfiguration['attempts'] ?? 3;
164+
$maximumAttempts = $retryConfiguration['attempts'] ?? self::DEFAULT_MAX_ATTEMPTS;
162165
$routingKey = str_replace('%attempt%', $attemptNumber, $retryConfiguration['routing_key_pattern']);
163166

164167
if ($attemptNumber > $maximumAttempts) {
@@ -233,7 +236,7 @@ private function retryQueue(array $retryConfiguration, int $attemptNumber)
233236
$queue = $this->amqpFactory->createQueue($this->channel());
234237
$queue->setName(str_replace('%attempt%', $attemptNumber, $retryConfiguration['queue_name_pattern']));
235238
$queue->setArguments(array(
236-
'x-message-ttl' => $retryConfiguration['ttl'][$attemptNumber - 1] ?? 10000, // 10 seconds by default
239+
'x-message-ttl' => $retryConfiguration['ttl'][$attemptNumber - 1] ?? self::DEFAULT_MESSAGE_TTL_IN_MILLI_SECONDS,
237240
'x-dead-letter-exchange' => $this->exchange()->getName(),
238241
));
239242

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.