feature: add ackwait config
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.
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.
Comment @coderabbitai help to get the list of available commands and usage tips.
@hungthai1401 @Kaspiman