Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Comments

feature: add ackwait config#75

Merged
roxblnfk merged 5 commits intoroadrunner-php:4.xfrom
shellphy:add_ack_wait
Nov 5, 2025
Merged

feature: add ackwait config#75
roxblnfk merged 5 commits intoroadrunner-php:4.xfrom
shellphy:add_ack_wait

Conversation

@shellphy
Copy link
Contributor

@shellphy shellphy commented Oct 25, 2025

related to roadrunner-server #190

Summary by CodeRabbit

  • New Features
    • NATS queue creation gains a configurable ack-wait time (defaults to 0), validated as non-negative and included in serialized output.
  • Tests
    • Unit tests updated to verify the new ack-wait property and its serialized representation.
  • Refactor
    • Kafka consumer offset class made final to clarify its intended usage.

@coderabbitai
Copy link

coderabbitai bot commented Oct 25, 2025

Walkthrough

Added a non-negative integer ackWait (default 0) to NatsCreateInfo; constructor asserts ackWait >= 0 and toArray() now includes 'ack_wait'. Added unit test updates. Also made ConsumerOffset a final class.

Changes

Cohort / File(s) Summary
NatsCreateInfo configuration parameter
src/Queue/NatsCreateInfo.php
Added public const ACK_WAIT_DEFAULT_VALUE = 0; added public readonly int $ackWait parameter to constructor (default self::ACK_WAIT_DEFAULT_VALUE); added \assert($ackWait >= 0, 'Precondition [ackWait >= 0] failed');; updated docblock; included 'ack_wait' => $this->ackWait in toArray()
Unit tests updated for new parameter
tests/Unit/Queue/NatsCreateInfoTest.php
Updated constructor calls to pass new ackWait argument (0); added assertion for $natsCreateInfo->ackWait === 0; updated toArray() expectation to include 'ack_wait' => 0
Class finalization
src/Queue/Kafka/ConsumerOffset.php
Changed class declaration to final class ConsumerOffset implements \JsonSerializable (no other behavior changes)

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Check assertion placement and message in src/Queue/NatsCreateInfo.php.
  • Verify serialization key 'ack_wait' aligns with external API/contract.
  • Confirm tests cover construction and toArray mapping; consider adding negative-value test if desired.

Suggested labels

enhancement

Suggested reviewers

  • wolfy-j
  • rustatian

Poem

I hopped into code with tiny feet,
A zero wait made the message neat,
Asserted safe, then tucked away—
NATS acks pause for a calmer day 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "feature: add ackwait config" directly and clearly describes the primary change in this changeset. The main modifications involve adding a new ackWait parameter to the NatsCreateInfo class constructor, updating the docblock, adding validation, and updating the toArray method to include this new field. The title is concise, uses clear language without noise or vague terms, and a teammate scanning the commit history would immediately understand that this PR introduces ackwait configuration functionality. While there is a secondary change to make ConsumerOffset final, the title appropriately focuses on the main feature being introduced.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 20cfcd5 and c5f8f2e.

📒 Files selected for processing (1)
  • src/Queue/NatsCreateInfo.php (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/Queue/NatsCreateInfo.php (4)
src/Queue/AMQPCreateInfo.php (1)
  • __construct (39-69)
src/Queue/SQSCreateInfo.php (1)
  • __construct (50-71)
src/Queue/BeanstalkCreateInfo.php (1)
  • __construct (25-38)
src/Queue/CreateInfo.php (1)
  • __construct (19-26)
🔇 Additional comments (3)
src/Queue/NatsCreateInfo.php (3)

18-18: LGTM: Constant definition is appropriate.

The constant follows the established pattern and a default value of 0 is reasonable for an acknowledgement wait timeout.


27-27: LGTM: Documentation is correct.

The docblock properly documents the parameter type and constraints.


60-60: LGTM: Serialization is correctly implemented.

The array key uses snake_case naming consistent with other fields, and the serialization follows the established pattern. Once the type mismatch on line 39 is corrected, this will function properly.

Copy link

@coderabbitai coderabbitai bot left a 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

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c5f8f2e and ec6141a.

📒 Files selected for processing (2)
  • src/Queue/NatsCreateInfo.php (4 hunks)
  • tests/Unit/Queue/NatsCreateInfoTest.php (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Queue/NatsCreateInfo.php
🔇 Additional comments (3)
tests/Unit/Queue/NatsCreateInfoTest.php (3)

24-26: LGTM!

The constructor call correctly includes the new ackWait parameter with a value of 0.


52-54: LGTM!

The constructor call is consistent with the first test and correctly includes the new ackWait parameter.


67-67: LGTM!

The expected array correctly includes the new ack_wait field with the appropriate value and naming convention.

Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (1)
src/Queue/Kafka/ConsumerOffset.php (1)

12-16: Consider adding validation for the $value parameter constraint.

The docblock specifies int<0,max>|null for $value, but there's no runtime assertion to enforce that $value >= 0 when provided. This inconsistency is notable given that the related NatsCreateInfo class (mentioned in the PR summary) includes an assertion for its similar ackWait parameter.

Apply this diff to add validation:

 public function __construct(
     public readonly OffsetType $type,
     public readonly ?int $value = null,
 ) {
+    assert($value === null || $value >= 0, 'Value must be non-negative');
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 057d0fb and d4cadcb.

📒 Files selected for processing (1)
  • src/Queue/Kafka/ConsumerOffset.php (1 hunks)
🔇 Additional comments (1)
src/Queue/Kafka/ConsumerOffset.php (1)

7-7: No breaking changes detected—the class is safe to make final.

The codebase contains no extensions of ConsumerOffset. The class is used only through composition (as a property type in ConsumePartition and ConsumerOptions) and direct instantiation in tests. Making it final is not a breaking change and aligns well with the class's immutable data-holding design.

@shellphy
Copy link
Contributor Author

shellphy commented Nov 4, 2025

@hungthai1401 @Kaspiman

@butschster butschster added the enhancement New feature or request label Nov 4, 2025
@roxblnfk roxblnfk merged commit cfa65ca into roadrunner-php:4.x Nov 5, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants