-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for ack, nack, and requeue methods #66
Conversation
WalkthroughThe recent updates to the Changes
Sequence Diagram(s)sequenceDiagram
participant Consumer
participant RabbitMQ
Consumer->>RabbitMQ: Process message
RabbitMQ->>Consumer: Processing Successful (ack)
Consumer-->>RabbitMQ: ack()
Consumer->>RabbitMQ: Process message
RabbitMQ-->>Consumer: Processing Failed (nack/redeliver)
Consumer-->>RabbitMQ: nack(redelivery: true)
Consumer->>RabbitMQ: Process message
RabbitMQ->>Consumer: Error Occurred
Consumer-->>RabbitMQ: requeue(with headers and delay)
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Outside diff range and nitpick comments (1)
README.md (1)
Line range hint
4-4
: Add alternate text to images for accessibility.Images in lines 4 and 17 lack alt text, which is important for accessibility and SEO.
- <img align="center" src="https://github.com/roadrunner-server/.github/assets/8040338/040fb694-1dd3-4865-9d29-8e0748c2c8b8"> + <img align="center" src="https://github.com/roadrunner-server/.github/assets/8040338/040fb694-1dd3-4865-9d29-8e0748c2c8b8" alt="RoadRunner Jobs Plugin Logo"> - <img src="https://user-images.githubusercontent.com/773481/220979012-e67b74b5-3db1-41b7-bdb0-8a042587dedc.jpg" alt="try Spiral Framework" /> + <img src="https://user-images.githubusercontent.com/773481/220979012-e67b74b5-3db1-41b7-bdb0-8a042587dedc.jpg" alt="Spiral Framework Advertisement" />Also applies to: 17-17
Tools
LanguageTool
[style] ~118-~118: The phrase ‘have the ability to’ might be wordy. Consider using “can”. (HAS_THE_ABILITY_TO)
Context: ...; ``` Thenack
and `requeue` methods have the ability to specify a delay for requeuing the t...
[style] ~118-~118: Consider a more expressive alternative. (DO_ACHIEVE)
Context: ... a delay for requeuing the task. To do this, call thewithDelay
method and ...Markdownlint
103-103: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces
118-118: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- README.md (2 hunks)
- src/Task/ReceivedTask.php (2 hunks)
- src/Task/ReceivedTaskInterface.php (2 hunks)
- src/Task/Type.php (1 hunks)
- tests/Unit/Task/ReceivedTaskTest.php (4 hunks)
Additional context used
LanguageTool
README.md
[style] ~10-~10: Using many exclamation marks might seem excessive (in this case: 6 exclamation marks for a text that’s 2916 characters long) (EN_EXCESSIVE_EXCLAMATION)
Context: ...st.org/packages/spiral/roadrunner-jobs)![]()
![]()
![]()
![]()
[
Context: ...endor/bin/rr get ``` ## Configuration First you need to add at least one jobs adapt...
[style] ~118-~118: The phrase ‘have the ability to’ might be wordy. Consider using “can”. (HAS_THE_ABILITY_TO)
Context: ...; ``` Thenack
and `requeue` methods have the ability to specify a delay for requeuing the t...
[style] ~118-~118: Consider a more expressive alternative. (DO_ACHIEVE)
Context: ... a delay for requeuing the task. To do this, call thewithDelay
method and ...
Markdownlint
README.md
103-103: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces
118-118: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces
4-4: null (MD045, no-alt-text)
Images should have alternate text (alt text)
17-17: null (MD045, no-alt-text)
Images should have alternate text (alt text)
Additional comments not posted (18)
src/Task/Type.php (5)
14-14
: Deprecation notice is clear and well-documented.The deprecation comment for
SUCCESS
clearly indicates the version and the alternative to use, which is a good practice for maintainability.
20-20
: Deprecation notice is clear and well-documented.The deprecation comment for
ERROR
is clear about the version and provides alternatives (NACK
orREQUEUE
), which helps in transitioning to the new constants.
27-27
: New constantACK
introduced correctly.The introduction of the
ACK
constant is aligned with the PR objectives to handle task acknowledgments more explicitly.
32-32
: New constantNACK
introduced correctly.The
NACK
constant provides a clear way to handle negative acknowledgments, which is crucial for error handling in task processing.
37-37
: New constantREQUEUE
introduced correctly.The
REQUEUE
constant supports the new feature of re-queuing tasks, which is essential for maintaining message order as per the linked issue discussion.src/Task/ReceivedTaskInterface.php (3)
12-14
: New method signatures forack
,nack
, andrequeue
are well-defined.These methods are crucial for the new functionality introduced in the PR and are well-documented in the interface.
25-25
: Deprecation ofcomplete
is well-documented.The method
complete
is deprecated in favor ofack
, which is aligned with the new task handling strategy.
33-33
: Deprecation offail
is well-documented.The method
fail
is deprecated in favor ofnack
andrequeue
, which provides more granular control over task failures.src/Task/ReceivedTask.php (5)
91-94
: Implementation ofack
method is correct and concise.The method correctly uses the new
Type::ACK
constant and ensures the task is marked as completed.
96-102
: Implementation ofnack
method is detailed and handles redelivery.The method correctly uses the
Type::NACK
constant and allows for optional redelivery, which is essential for robust task processing.
105-117
: Implementation ofrequeue
method is robust and flexible.The method correctly uses the
Type::REQUEUE
constant and supports additional headers and delay, aligning with the PR objectives.
66-67
: Deprecation ofcomplete
method is clear and directs users to the newack
method.
74-75
: Deprecation offail
method is clear and directs users to the newnack
andrequeue
methods.README.md (1)
96-123
: Documentation update is comprehensive and clear.The updated sections clearly explain the functionality of the new
ack
,nack
, andrequeue
methods, including parameters and behavior. This is crucial for users to understand how to use the new features.Tools
LanguageTool
[style] ~118-~118: The phrase ‘have the ability to’ might be wordy. Consider using “can”. (HAS_THE_ABILITY_TO)
Context: ...; ``` Thenack
and `requeue` methods have the ability to specify a delay for requeuing the t...
[style] ~118-~118: Consider a more expressive alternative. (DO_ACHIEVE)
Context: ... a delay for requeuing the task. To do this, call thewithDelay
method and ...Markdownlint
103-103: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces
118-118: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spacestests/Unit/Task/ReceivedTaskTest.php (4)
8-8
: New import added forDataProvider
.This import is necessary to utilize the
#[DataProvider]
attribute in the test methods, which allows for parameterized tests. This is a good practice as it enhances the test's flexibility and reusability.
83-106
: Review of thetestAck
method.This method tests the
ack
functionality of theReceivedTask
. The test is well-structured, simulating the task's completion and success without failure. The mock setup and assertions are appropriate and check the payload structure correctly. The transition fromType::SUCCESS
toType::ACK
is correctly implemented in the test.
116-156
: Review of thetestNack
method with data provider.The method correctly uses a data provider to test various scenarios of the
nack
functionality. The handling of theredelivery
anddelay
parameters is well done, and the method correctly asserts the state transitions and the response payload structure. However, ensure that theredelivery
boolean is handled correctly in all cases, especially when it affects the payload structure significantly.
159-203
: Review of thetestRequeue
method with data provider.This method is well-implemented, testing the
requeue
functionality with various configurations of delays and headers. The use of a data provider enhances test coverage. The assertions on the task state and payload content are precise, ensuring that therequeue
functionality is working as expected, including the handling of headers in the payload.
[APROVED]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/Task/ReceivedTask.php (2 hunks)
Additional comments not posted (5)
src/Task/ReceivedTask.php (5)
65-67
: Deprecation notice forcomplete()
method is clear and well-documented.
73-75
: Deprecation notice forfail()
method is clear and well-documented.
91-94
: Implementation ofack()
method is correct and straightforward.The method correctly uses the
Type::ACK
constant to respond to success. This aligns well with the PR's objective of enhancing message acknowledgment handling.
129-129
: Update status check methods to include new constants.The updates to
isSuccessful()
andisFails()
methods to include checks forType::ACK
,Type::NACK
, andType::REQUEUE
are appropriate and align with the changes in method functionality. This ensures that the task statuses are accurately reflected.Also applies to: 134-136
108-120
: Review the implementation ofrequeue()
method.The
requeue()
method correctly uses theType::REQUEUE
constant and includes handling for delayed re-queueing and header adjustments. This method is crucial for addressing the linked issue regarding message order preservation. Ensure that the headers manipulation and delay settings are explicitly tested to confirm they meet the expected behavior.Verification successful
Verified: The
testRequeue
method adequately tests the delay and headers handling in therequeue
method.
- The test checks if the task is correctly updated with delay and headers.
- It verifies that the
respond
method is called with the appropriate payload, including delay and headers.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify if delay and headers are handled correctly in the requeue method. # Test: Search for unit tests covering delay and header manipulation in requeue method. rg --type php 'testRequeue'Length of output: 165
Script:
#!/bin/bash # Extract the implementation of the testRequeue function from the relevant file. ast-grep --lang php --pattern 'function testRequeue($_, $_, $_, $_) { $$$ }' tests/Unit/Task/ReceivedTaskTest.phpLength of output: 222
Script:
#!/bin/bash # Locate the testRequeue function definition and extract surrounding lines. rg -A 20 'function testRequeue' tests/Unit/Task/ReceivedTaskTest.phpLength of output: 792
Script:
#!/bin/bash # Extract additional lines to capture the complete implementation of the testRequeue function. rg -A 40 'function testRequeue' tests/Unit/Task/ReceivedTaskTest.phpLength of output: 1393
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 4.x #66 +/- ##
============================================
+ Coverage 86.87% 87.25% +0.38%
- Complexity 197 204 +7
============================================
Files 30 30
Lines 602 620 +18
============================================
+ Hits 523 541 +18
Misses 79 79 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range and nitpick comments (2)
README.md (2)
98-100
: Clarify the purpose of the methods for better understanding.The methods
ack
,nack
, andrequeue
are mentioned, but a brief explanation of each could enhance clarity for users unfamiliar with these terms.
111-113
: Explain the independence of therequeue
method from the queue driver.It's valuable to highlight that the
requeue
method's functionality does not depend on the queue driver, which is a significant aspect of its behavior.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- README.md (2 hunks)
- src/Task/ReceivedTask.php (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/Task/ReceivedTask.php
Additional context used
LanguageTool
README.md
[style] ~10-~10: Using many exclamation marks might seem excessive (in this case: 6 exclamation marks for a text that’s 2916 characters long) (EN_EXCESSIVE_EXCLAMATION)
Context: ...st.org/packages/spiral/roadrunner-jobs)![]()
![]()
![]()
![]()
[
Context: ...; ``` Thenack
and `requeue` methods have the ability to specify a delay for requeuing the t...
[style] ~118-~118: Consider a more expressive alternative. (DO_ACHIEVE)
Context: ... a delay for requeuing the task. To do this, call thewithDelay
method and ...
Markdownlint
README.md
103-103: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces
118-118: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces
4-4: null (MD045, no-alt-text)
Images should have alternate text (alt text)
17-17: null (MD045, no-alt-text)
Images should have alternate text (alt text)
Additional comments not posted (2)
README.md (2)
103-105
: Clarify theredelivery
parameter's behavior.The description of the
redelivery
parameter's behavior could be clearer. It's important to explicitly mention that settingredelivery
totrue
attempts to requeue the task, but this is contingent on the driver's support.Tools
Markdownlint
103-103: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces
145-147
: Ensure proper error handling in the Consumer code snippet.The catch block for handling errors in the Consumer code snippet is critical. It would be beneficial to ensure that all possible exceptions are appropriately handled and logged.
The `nack` and `requeue` methods have the ability to specify a **delay** for requeuing the task. To do this, call | ||
the `withDelay` method and pass the desired value before invoking the `nack` or `requeue` methods. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify language for setting delays in requeuing.
The current phrasing could be simplified for better readability and understanding.
- The `nack` and `requeue` methods have the ability to specify a **delay** for requeuing the task. To do this, call
- the `withDelay` method and pass the desired value before invoking the `nack` or `requeue` methods.
+ The `nack` and `requeue` methods can set a **delay** for requeuing tasks by calling `withDelay` with the desired value before invocation.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
The `nack` and `requeue` methods have the ability to specify a **delay** for requeuing the task. To do this, call | |
the `withDelay` method and pass the desired value before invoking the `nack` or `requeue` methods. | |
The `nack` and `requeue` methods can set a **delay** for requeuing tasks by calling `withDelay` with the desired value before invocation. |
Tools
LanguageTool
[style] ~118-~118: The phrase ‘have the ability to’ might be wordy. Consider using “can”. (HAS_THE_ABILITY_TO)
Context: ...; ``` Thenack
and `requeue` methods have the ability to specify a delay for requeuing the t...
[style] ~118-~118: Consider a more expressive alternative. (DO_ACHIEVE)
Context: ... a delay for requeuing the task. To do this, call thewithDelay
method and ...
Markdownlint
118-118: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces
Added support for
ack
,nack
, andrequeue
methods.Closes: roadrunner-server/roadrunner#1941