Skip to content

Conversation

abnegate
Copy link
Member

@abnegate abnegate commented Jul 4, 2025

Summary by CodeRabbit

  • New Features

    • Added support for configurable publisher acknowledgments and retry logic when publishing messages via AMQP.
    • Introduced new end-to-end tests for AMQP and AMQPSwoole publishing with acknowledgments enabled.
  • Chores

    • Broadened version constraints for several dependencies to allow for greater flexibility in updates.
    • Expanded the test matrix in CI workflows to include new adapter types.
  • Style

    • Improved code style for callable checks and invocation in AMQP-related classes.
    • Reformatted constructor calls for better readability in test classes.

Copy link

coderabbitai bot commented Jul 4, 2025

Warning

Rate limit exceeded

@abnegate has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 23 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between afa3cfa and 2b85380.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • composer.json (1 hunks)
  • src/Queue/Broker/AMQP.php (7 hunks)
  • src/Queue/Broker/AMQPSwoole.php (1 hunks)

Walkthrough

The changes introduce publisher confirm support and retry logic to the AMQP broker, allowing configurable reliability for message publishing. Dependency version constraints in composer.json are broadened. The AMQPSwoole broker's connection instantiation is simplified. New end-to-end tests for AMQP with acknowledgments and AMQPSwoole with acknowledgments are added. The test matrix is updated to include new adapters.

Changes

File(s) Change Summary
.github/workflows/tests.yml Expanded test matrix to include AMQPAck and AMQPSwoole adapters.
composer.json Broadened version constraints for several dependencies in "require" and "require-dev" sections; added memory limit to PHPStan check script.
src/Queue/Broker/AMQP.php Added publisher confirm support, retry logic, new properties, and setter methods; improved callable invocation; enhanced error handling; coroutine-aware channel management.
src/Queue/Broker/AMQPSwoole.php Simplified connection instantiation using named arguments; modernized callable checks and invocation style.
tests/Queue/E2E/Adapter/AMQPAckTest.php Added new E2E test for AMQP with acknowledgment enabled.
tests/Queue/E2E/Adapter/AMQPSwooleAckTest.php Added new E2E test for AMQPSwoole with acknowledgment enabled, including coroutine-based concurrency and retry tests.
tests/Queue/E2E/Adapter/AMQPSwooleTest.php Reformatted constructor call for readability, no logic change.
tests/Queue/E2E/Adapter/AMQPTest.php Reformatted constructor call for readability, no logic change.

Sequence Diagram(s)

sequenceDiagram
    participant Test as AMQPAckTest / AMQPSwooleAckTest
    participant Publisher as AMQP / AMQPSwoole Publisher
    participant Broker as AMQP / AMQPSwoole Broker
    participant Queue as Queue

    Test->>Publisher: getPublisher(requireAck=true)
    Test->>Queue: getQueue()
    Publisher->>Broker: enqueue(Queue, payload)
    alt requireAck = true
        Broker->>Broker: publish message (retry up to maxEnqueueAttempts)
        Broker->>Broker: wait_for_pending_acks(timeout)
        Broker-->>Publisher: success/failure
    else requireAck = false
        Broker->>Broker: publish message (no confirm)
        Broker-->>Publisher: success/failure
    end
Loading

Possibly related PRs

Poem

In the warren of queues, a change hops in,
Reliable messages—let the confirms begin!
With retries and timeouts, the brokers now boast,
New tests and adapters, the rabbits can toast.
Composer’s constraints now stretch and grow—
Hopping forward, the queues will flow! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d61c06 and 1185ef2.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • .github/workflows/tests.yml (1 hunks)
  • composer.json (1 hunks)
  • src/Queue/Broker/AMQP.php (6 hunks)
  • src/Queue/Broker/AMQPSwoole.php (1 hunks)
  • tests/Queue/E2E/Adapter/AMQPAckTest.php (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
tests/Queue/E2E/Adapter/AMQPAckTest.php (3)
src/Queue/Queue.php (1)
  • Queue (5-15)
tests/Queue/E2E/Adapter/Base.php (1)
  • Base (11-130)
src/Queue/Broker/AMQP.php (1)
  • AMQP (24-297)
src/Queue/Broker/AMQP.php (2)
src/Queue/Message.php (1)
  • Message (5-81)
src/Queue/Broker/AMQPSwoole.php (1)
  • withChannel (16-56)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Adapter Tests (SwooleRedisCluster)
  • GitHub Check: Adapter Tests (Workerman)
  • GitHub Check: Adapter Tests (Swoole)
🔇 Additional comments (7)
composer.json (1)

28-28: LGTM!

The more restrictive version constraint ensures stability while allowing patch-level updates.

tests/Queue/E2E/Adapter/AMQPAckTest.php (1)

10-21: LGTM!

The test correctly configures AMQP with publisher acknowledgments enabled, providing coverage for the new acknowledgment feature.

src/Queue/Broker/AMQPSwoole.php (2)

25-28: LGTM!

Using named parameters improves code clarity and maintainability.


30-32: LGTM!

The modernized callable handling using \is_callable and direct invocation is cleaner and more performant than call_user_func.

Also applies to: 36-38

src/Queue/Broker/AMQP.php (3)

42-56: LGTM!

The new acknowledgment-related parameters have sensible defaults that balance reliability and performance.


183-212: LGTM!

The retry logic with publisher confirms is well-implemented, handling connection issues gracefully while respecting the configured maximum attempts.


266-279: LGTM!

The modernized callable handling and conditional publisher confirms setup are implemented correctly.

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: 2

🧹 Nitpick comments (1)
tests/Queue/E2E/Adapter/AMQPSwooleAckTest.php (1)

41-41: Consider making sleep durations configurable.

The hard-coded sleep(1) values may need adjustment based on different environments or testing scenarios. Consider extracting these as constants or configuration parameters.

+    private const TEST_SLEEP_DURATION = 1;
+
     // Then replace all sleep(1) calls with:
-    sleep(1);
+    sleep(self::TEST_SLEEP_DURATION);

Also applies to: 57-57, 101-101, 103-103, 105-105

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0d8b72 and 5d08ed7.

📒 Files selected for processing (5)
  • src/Queue/Broker/AMQP.php (7 hunks)
  • tests/Queue/E2E/Adapter/AMQPAckTest.php (1 hunks)
  • tests/Queue/E2E/Adapter/AMQPSwooleAckTest.php (1 hunks)
  • tests/Queue/E2E/Adapter/AMQPSwooleTest.php (1 hunks)
  • tests/Queue/E2E/Adapter/AMQPTest.php (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • tests/Queue/E2E/Adapter/AMQPSwooleTest.php
  • tests/Queue/E2E/Adapter/AMQPTest.php
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/Queue/E2E/Adapter/AMQPAckTest.php
  • src/Queue/Broker/AMQP.php
🧰 Additional context used
🪛 GitHub Actions: Linter
tests/Queue/E2E/Adapter/AMQPSwooleAckTest.php

[error] 1-1: PSR 12 style issue: blank line between import groups missing. Run 'vendor/bin/pint --write' to fix code style issues.

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Adapter Tests (Pool)
  • GitHub Check: Adapter Tests (Workerman)
  • GitHub Check: Adapter Tests (AMQPAck)
  • GitHub Check: Adapter Tests (AMQP)
  • GitHub Check: Adapter Tests (SwooleRedisCluster)
  • GitHub Check: Adapter Tests (Swoole)
  • GitHub Check: Adapter Tests (AMQPSwoole)
🔇 Additional comments (3)
tests/Queue/E2E/Adapter/AMQPSwooleAckTest.php (3)

13-22: LGTM! Publisher configuration looks correct.

The AMQPSwoole broker is properly configured with acknowledgment enabled, which aligns with the test's purpose of testing the ack functionality.


24-27: LGTM! Queue configuration is appropriate.

The queue name 'amqp-swoole' clearly indicates the broker type being tested.


68-110: LGTM! Retry test logic is comprehensive.

The retry test properly validates the retry functionality with different parameters and follows good testing practices with the @Depends annotation.

Comment on lines -90 to 91
match (true) {
$result instanceof Commit => $amqpMessage->ack(true),
$result instanceof NoCommit => null,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed because ack(true) acknowledges all prior messages. So if they fail, they can't be re-queued or sent to the failed queue. Consumer should only acknowledge the current message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant