Skip to content

Commit caecc7d

Browse files
Merge pull request #22 from run-as-root/develop
Improves the retry limit query
2 parents 785cbde + 0d7595a commit caecc7d

File tree

4 files changed

+43
-10
lines changed

4 files changed

+43
-10
lines changed

Diff for: composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Provides message queue retry processing functionality via RabbitMQ's dead letter exchange.",
44
"type": "magento2-module",
55
"license": "MIT",
6-
"version": "2.0.0",
6+
"version": "2.0.1",
77
"authors": [
88
{
99
"name": "Cristiano Pacheco",

Diff for: composer.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/Repository/Query/FindQueueRetryLimitByTopicNameQuery.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,20 @@ public function __construct(private DataInterface $configStorage)
1515

1616
public function execute(string $topicName): ?int
1717
{
18-
$configKey = QueueRetryConfigInterface::CONFIG_KEY_NAME . '/' . $topicName;
19-
$queueRetryTopic = $this->configStorage->get($configKey);
18+
$topics = $this->configStorage->get(QueueRetryConfigInterface::CONFIG_KEY_NAME);
19+
20+
if (!$topics) {
21+
return null;
22+
}
23+
24+
$queueRetryTopic = $topics[$topicName] ?? null;
2025

2126
if (!$queueRetryTopic) {
2227
return null;
2328
}
2429

25-
$retryLimitKey = QueueRetryConfigInterface::RETRY_LIMIT;
26-
return isset($queueRetryTopic[$retryLimitKey]) ? (int)$queueRetryTopic[$retryLimitKey] : null;
30+
$retryLimit = $queueRetryTopic[QueueRetryConfigInterface::RETRY_LIMIT] ?? null;
31+
32+
return $retryLimit ? (int)$retryLimit : null;
2733
}
2834
}

Diff for: src/Test/Unit/Repository/Query/FindQueueRetryLimitByTopicNameQueryTest.php

+31-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function setUp(): void
2424
*/
2525
public function testExecute($expected, $topicName, $config): void
2626
{
27-
$configKey = QueueRetryConfigInterface::CONFIG_KEY_NAME . '/' . $topicName;
27+
$configKey = QueueRetryConfigInterface::CONFIG_KEY_NAME;
2828
$this->configStorageMock->expects($this->once())->method('get')->with($configKey)->willReturn($config);
2929

3030
$result = $this->sut->execute($topicName);
@@ -35,9 +35,36 @@ public function testExecute($expected, $topicName, $config): void
3535
public function dataProvider(): array
3636
{
3737
return [
38-
[3, 'sample_topic', ['retry_limit' => '3']],
39-
[null, 'sample_topic', ['some_key' => '3']],
40-
[null, 'sample_topic', null],
38+
[
39+
5,
40+
'sample_topic',
41+
[
42+
'sample_topic' => ['retry_limit' => '5'],
43+
'sample_topic2' => ['retry_limit' => '3'],
44+
'sample_topic3' => ['retry_limit' => '8']
45+
],
46+
],
47+
[
48+
3,
49+
'sample_topic2',
50+
[
51+
'sample_topic' => ['retry_limit' => '5'],
52+
'sample_topic2' => ['retry_limit' => '3'],
53+
'sample_topic3' => ['retry_limit' => '8']
54+
],
55+
],
56+
[
57+
null,
58+
'sample_topic2',
59+
[
60+
'sample_topic' => ['retry_limit' => '5'],
61+
],
62+
],
63+
[
64+
null,
65+
'sample_topic2',
66+
null,
67+
],
4168
];
4269
}
4370
}

0 commit comments

Comments
 (0)