Skip to content

Conversation

christyjacob4
Copy link
Contributor

@christyjacob4 christyjacob4 commented Jun 23, 2025

  • Replaced php-amqplib/php-amqplib with appwrite-labs/php-amqplib in composer.json for Swoole support.
  • Added connection class flexibility in AMQP broker to allow using AMQPSwooleConnection.
  • Enhanced tests to cover both AMQPStreamConnection and AMQPSwooleConnection.
  • Updated various dependencies in composer.lock for compatibility and improvements.

Summary by CodeRabbit

  • New Features
    • Introduced support for AMQPSwoole as a new queue broker, enabling asynchronous and concurrent message processing.
    • Added a new test worker and end-to-end tests to validate AMQPSwoole integration and behavior.
  • Chores
    • Updated dependencies to use a new AMQP PHP library.
    • Enhanced Docker setup with a new AMQPSwoole service for testing and adjusted health checks for related services.

…ce test coverage

- Replaced php-amqplib/php-amqplib with appwrite-labs/php-amqplib in composer.json for Swoole support.
- Added connection class flexibility in AMQP broker to allow using AMQPSwooleConnection.
- Enhanced tests to cover both AMQPStreamConnection and AMQPSwooleConnection.
- Updated various dependencies in composer.lock for compatibility and improvements.
Copy link

coderabbitai bot commented Jun 23, 2025

Walkthrough

The changes introduce a new AMQPSwoole queue broker implementation with associated end-to-end tests and a worker script for Swoole-based asynchronous message processing. Visibility of certain properties and methods in the AMQP class is updated to support extension. Docker Compose is modified to add an amqp-swoole service and adjust health checks. The AMQP library dependency is switched to a forked version.

Changes

File(s) Change Summary
composer.json Changed AMQP PHP library dependency to "appwrite-labs/php-amqplib" version "^0.1".
src/Queue/Broker/AMQP.php Changed visibility of properties and constructor parameters from private to protected; changed method withChannel visibility to protected.
src/Queue/Broker/AMQPSwoole.php Added new AMQPSwoole class extending AMQP, overriding withChannel to use AMQPSwooleConnection with retry logic.
tests/Queue/E2E/Adapter/AMQPSwooleTest.php Added new E2E test class for AMQPSwoole broker, testing events, concurrency, and retry logic using Swoole coroutines.
tests/Queue/servers/AMQPSwoole/worker.php Added new worker script to run a queue worker using the AMQPSwoole broker and Swoole adapter with event handlers.
docker-compose.yml Added amqp-swoole service; updated tests service dependencies; added start_period: 0s to Redis cluster and AMQP healthchecks.

Sequence Diagram(s)

sequenceDiagram
    participant Test as AMQPSwooleTest
    participant Publisher as AMQPSwoole
    participant AMQPServer as AMQP/Swoole Server

    Test->>Publisher: Enqueue message(s)
    Publisher->>AMQPServer: Publish to exchange (with retry on failure)
    AMQPServer-->>Publisher: Ack/Nack

    Note over Test,AMQPServer: Tests run in Swoole coroutines for concurrency and retry scenarios
Loading
sequenceDiagram
    participant WorkerScript as worker.php
    participant Broker as AMQPSwoole
    participant Adapter as Swoole Adapter
    participant Server as Queue Server

    WorkerScript->>Broker: Initialize AMQPSwoole broker
    WorkerScript->>Adapter: Wrap broker with Swoole adapter (concurrency=12)
    WorkerScript->>Server: Create server with adapter
    Server->>WorkerScript: Register job, error, and start handlers
    WorkerScript->>Server: Start server (process jobs)
Loading

Poem

A Swoole breeze now fills the queue,
With AMQP and tests anew.
Worker scripts and coroutines run,
Async rabbits having fun.
Exchanges declared, retries in tow—
The message garden starts to grow!
🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 080639c and 91579cd.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • composer.json (1 hunks)
  • src/Queue/Broker/AMQP.php (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • composer.json
  • src/Queue/Broker/AMQP.php
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Adapter Tests (Workerman)
  • GitHub Check: Adapter Tests (AMQP)
  • GitHub Check: Adapter Tests (Pool)
  • GitHub Check: Adapter Tests (SwooleRedisCluster)
  • GitHub Check: Adapter Tests (Swoole)
✨ 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: 3

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 498bbbe and fc15d1a.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • composer.json (2 hunks)
  • src/Queue/Broker/AMQP.php (3 hunks)
  • tests/Queue/E2E/Adapter/AMQPTest.php (1 hunks)
  • tests/Queue/E2E/Adapter/Base.php (0 hunks)
💤 Files with no reviewable changes (1)
  • tests/Queue/E2E/Adapter/Base.php
🧰 Additional context used
🪛 GitHub Actions: Linter
src/Queue/Broker/AMQP.php

[error] 1-1: Laravel Pint linting failed: PSR 12 style issue 'no_unused_imports' detected.

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Adapter Tests (Swoole)
  • GitHub Check: Adapter Tests (Workerman)
  • GitHub Check: Adapter Tests (SwooleRedisCluster)
  • GitHub Check: Adapter Tests (AMQP)
  • GitHub Check: Adapter Tests (Pool)
🔇 Additional comments (3)
src/Queue/Broker/AMQP.php (2)

49-54: Well-implemented connection class parameter.

Good implementation with backward compatibility preserved through the default value and proper validation of the connection class inheritance.


194-203: Dynamic connection instantiation looks good.

The implementation correctly uses the dynamic class instantiation with proper parameter passing.

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

15-33: Well-structured test setup with proper Swoole extension checks.

Good use of data providers to test both connection types and appropriate test skipping when Swoole is unavailable.

…RabbitMQ

- Added start_period to healthcheck for Redis cluster services to ensure proper startup timing.
- Updated RabbitMQ service healthcheck to include start_period for improved reliability.
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 (3)
docker-compose.yml (3)

80-80: Use meaningful start_period for Redis cluster healthchecks

Explicitly setting start_period: 0s is effectively a no-op (the default is 0). This could lead to premature health check failures if the cluster nodes need time to start. Consider removing these entries or configuring a non-zero period (e.g., start_period: 30s) to allow Redis cluster nodes sufficient initialization time before health checks begin.

Also applies to: 91-91, 101-101, 113-113


123-124: Reevaluate RabbitMQ healthcheck timing

The newly added start_interval: 1s and start_period: 0s for the amqp service may cause false negatives if RabbitMQ requires a warm-up period. If startup latency is non-trivial, bump start_period to a suitable duration (for example, start_period: 30s) to prevent the container from being marked unhealthy prematurely.


124-124: Add newline at end of file

YAMLLint reports a missing newline at EOF. Please add a trailing newline to satisfy the linter.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fc15d1a and c119b29.

📒 Files selected for processing (2)
  • docker-compose.yml (5 hunks)
  • src/Queue/Broker/AMQP.php (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Queue/Broker/AMQP.php
🧰 Additional context used
🪛 YAMLlint (1.37.1)
docker-compose.yml

[error] 124-124: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Adapter Tests (Workerman)
  • GitHub Check: Adapter Tests (SwooleRedisCluster)
  • GitHub Check: Adapter Tests (AMQP)
  • GitHub Check: Adapter Tests (Swoole)

…structure

- Introduced a private property for connection class in AMQPTest to streamline publisher retrieval.
- Updated test methods to use the connection class directly, improving clarity and maintainability.
- Renamed test methods for better readability and consistency.
- Consolidated publisher retrieval logic into the Base class for reuse across tests.
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

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

30-32: Remove redundant Swoole extension check from getPublisher.

This Swoole extension check in getPublisher() is redundant since the concurrency test method (testConcurrencyWithConnection) already has a more appropriate check that only skips when the connection is not AMQPSwooleConnection.

-        if ($this->connectionClass === AMQPSwooleConnection::class && !extension_loaded('swoole')) {
-            $this->markTestSkipped('Swoole extension is not available');
-        }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c119b29 and ad824a3.

📒 Files selected for processing (2)
  • tests/Queue/E2E/Adapter/AMQPTest.php (1 hunks)
  • tests/Queue/E2E/Adapter/Base.php (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Linter
tests/Queue/E2E/Adapter/AMQPTest.php

[error] 1-1: PSR 12 linting failed: no_unused_imports and single_line_after_imports style issues detected.

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Adapter Tests (Pool)
  • GitHub Check: Adapter Tests (Workerman)
  • GitHub Check: Adapter Tests (Swoole)
  • GitHub Check: Adapter Tests (SwooleRedisCluster)
🔇 Additional comments (4)
tests/Queue/E2E/Adapter/Base.php (1)

77-79: LGTM! Prevents runtime errors when Swoole is unavailable.

The Swoole extension check is necessary since the concurrency test uses run() and go() functions from Swoole. This prevents runtime errors when the extension is not loaded.

Note: There's a slight inconsistency with the approach in AMQPTest.php where the check is more granular (only for AMQPSwooleConnection), but this blanket approach is safer for the base class.

tests/Queue/E2E/Adapter/AMQPTest.php (3)

17-23: Well-structured data provider for testing multiple connection types.

The data provider correctly provides both AMQPStreamConnection and AMQPSwooleConnection classes for comprehensive testing coverage.


58-60: Excellent granular control for concurrency testing.

This implementation correctly restricts concurrency testing to only AMQPSwooleConnection, which is more precise than the blanket Swoole extension check. This addresses the past review feedback effectively by allowing other connection types to run without Swoole.


71-74: Good workaround for data provider limitations with test dependencies.

The manual invocation of dependent tests is a valid approach since PHPUnit's @depends annotation doesn't work with data providers. The comment clearly explains this limitation.

…ss and adding debug output

- Commented out the AMQPSwooleConnection in the connection class array to streamline test configuration.
- Added a debug output statement in the testEventsWithConnection method for troubleshooting purposes.
- Removed the Swoole extension check from the testConcurrency method to avoid unnecessary test skips.
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

♻️ Duplicate comments (1)
tests/Queue/E2E/Adapter/AMQPTest.php (1)

11-11: Remove unused import causing linting failure.

This import was flagged in a previous review and is still causing linting failures. The concurrency logic is handled in the parent Base class.

-use function Co\run;
🧹 Nitpick comments (1)
tests/Queue/E2E/Adapter/AMQPTest.php (1)

28-35: Consider improving the method design pattern.

The functionality is correct, but relying on instance variables creates tight coupling. Consider if the connection class could be passed as a parameter instead of using instance state.

Alternative approach:

-protected function getPublisher(): Publisher
+protected function getPublisher(string $connectionClass = AMQPStreamConnection::class): Publisher
 {
-    if ($this->connectionClass === AMQPSwooleConnection::class && !extension_loaded('swoole')) {
+    if ($connectionClass === AMQPSwooleConnection::class && !extension_loaded('swoole')) {
         $this->markTestSkipped('Swoole extension is not available');
     }

-    return new AMQP(host: 'amqp', port: 5672, user: 'amqp', password: 'amqp', connectionClass: $this->connectionClass);
+    return new AMQP(host: 'amqp', port: 5672, user: 'amqp', password: 'amqp', connectionClass: $connectionClass);
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ad824a3 and 57033c0.

📒 Files selected for processing (1)
  • tests/Queue/E2E/Adapter/AMQPTest.php (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Linter
tests/Queue/E2E/Adapter/AMQPTest.php

[error] 1-1: PSR 12 linting failed: no_unused_imports and single_line_after_imports style issues detected.

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

17-23: Data provider structure is well-implemented.

Good use of data provider pattern for testing multiple connection types. The commented-out AMQPSwooleConnection suggests a phased approach to testing, which is reasonable.


69-76: Well-handled PHPUnit data provider limitation.

Good documentation and proper workaround for the limitation that @depends annotation doesn't work with data providers. The manual dependency handling is the correct approach here.

Comment on lines 55 to 64
public function testConcurrencyWithConnection(string $connectionClass): void
{
$this->connectionClass = $connectionClass;

if ($this->connectionClass !== AMQPSwooleConnection::class) {
$this->markTestSkipped('Concurrency test can only be run with Swoole');
}

parent::testConcurrency();
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Address logical inconsistency in concurrency test.

The test always skips because AMQPSwooleConnection is commented out in the data provider (line 21), making this test effectively disabled. Consider either:

  1. Enabling AMQPSwooleConnection in the data provider, or
  2. Adding a condition to only run this test when the connection supports concurrency
🤖 Prompt for AI Agents
In tests/Queue/E2E/Adapter/AMQPTest.php around lines 55 to 64, the concurrency
test is always skipped because AMQPSwooleConnection is commented out in the data
provider at line 21. To fix this, either uncomment and enable
AMQPSwooleConnection in the data provider so the test runs with a compatible
connection, or modify the test to conditionally run only when the connection
supports concurrency by adding appropriate checks before skipping.

- Replaced appwrite-labs/php-amqplib with appwrite/php-amqplib version 0.1.0 in composer.json and composer.lock for improved stability.
- Changed visibility of properties and methods in the AMQP class from private to protected to enhance extensibility.
- Removed unused connection class references and streamlined the AMQPTest class for better clarity and maintainability.
- Removed unnecessary whitespace in the AMQPSwoole class to improve code readability.
- Ensured consistent formatting by adding a newline at the end of the file.
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/Broker/AMQPSwoole.php (1)

27-27: Consider making locale configurable instead of hardcoding.

The locale is hardcoded as 'en_US', which may not be suitable for international deployments. Consider making this configurable through a class property or method parameter.

-                'en_US', // locale
+                $this->locale ?? 'en_US', // locale

You would also need to add a $locale property to the parent class or make it configurable during construction.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 57033c0 and d46c4f2.

⛔ 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 (2 hunks)
  • src/Queue/Broker/AMQPSwoole.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • composer.json
  • src/Queue/Broker/AMQP.php
🔇 Additional comments (3)
src/Queue/Broker/AMQPSwoole.php (3)

8-63: LGTM! Well-structured Swoole integration with proper error handling.

The class implementation follows good practices:

  • Proper inheritance and method overriding
  • Clean separation of connection creation logic
  • Appropriate use of configuration hooks
  • Reasonable retry mechanism for transient failures
  • Good documentation and code organization

The integration appears well-designed for Swoole environments while maintaining compatibility with the existing AMQP broker interface.


18-34: ```shell
#!/bin/bash

Locate the AMQPSwooleConnection class file

FILE=$(rg --files-with-matches "class AMQPSwooleConnection" | head -n1)
echo "Found class definition in: $FILE"

Display the constructor signature with context

grep -R -n -C 3 "function __construct" "$FILE"


---

`53-61`: ```shell
#!/bin/bash
# Locate the AMQPSwooleConnection class file
file=$(rg --files-with-matches -e "class AMQPSwooleConnection" -t php)
echo "Found file: $file"

# Display the first 200 lines to inspect for cleanup logic
sed -n '1,200p' "$file"

# Search specifically for destructor and close methods
rg -n "function __destruct" "$file"
rg -n "function close" "$file"

- Replaced appwrite/php-amqplib with appwrite-labs/php-amqplib in composer.json for better compatibility.
- Added amqp-swoole service to docker-compose.yml for improved testing capabilities.
- Updated phpunit.xml to enable process isolation and stop on failure for more robust test execution.
- Simplified test methods by removing redundant go function declarations and utilizing the publisher directly.
- Added retry logic in the testRetry method for enhanced testing of message retries.
- Ensured consistent formatting by adding a newline at the end of the worker.php file.
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: 3

🧹 Nitpick comments (1)
docs/AMQPSwoole.md (1)

11-13: Specify language for fenced code block.

Add language specification to the error message code block for better syntax highlighting.

-```
+```text
 Fatal error: Uncaught Swoole\Error: API must be called in the coroutine

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

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


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between d46c4f2ecf1999da6a2027044d2fcd8a7252f67e and 12808fdf46fea7c6349bb48f49b9cc12ee22fb43.

</details>

<details>
<summary>📒 Files selected for processing (7)</summary>

* `composer.json` (1 hunks)
* `docker-compose.yml` (7 hunks)
* `docs/AMQPSwoole.md` (1 hunks)
* `phpunit.xml` (1 hunks)
* `tests/Queue/E2E/Adapter/AMQPSwooleTest.php` (1 hunks)
* `tests/Queue/servers/AMQPSwoole/Dockerfile` (1 hunks)
* `tests/Queue/servers/AMQPSwoole/worker.php` (1 hunks)

</details>

<details>
<summary>✅ Files skipped from review due to trivial changes (2)</summary>

* phpunit.xml
* tests/Queue/servers/AMQPSwoole/Dockerfile

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* composer.json

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🪛 GitHub Actions: Linter</summary>

<details>
<summary>tests/Queue/servers/AMQPSwoole/worker.php</summary>

[error] 1-1: Laravel Pint PSR-12 style check failed: no_trailing_whitespace and single blank line issues detected.

</details>
<details>
<summary>tests/Queue/E2E/Adapter/AMQPSwooleTest.php</summary>

[error] 1-1: Laravel Pint PSR-12 style check failed: no_trailing_whitespace and single blank line issues detected.

</details>

</details>
<details>
<summary>🪛 YAMLlint (1.37.1)</summary>

<details>
<summary>docker-compose.yml</summary>

[error] 137-137: no new line character at the end of file

(new-line-at-end-of-file)

</details>

</details>
<details>
<summary>🪛 LanguageTool</summary>

<details>
<summary>docs/AMQPSwoole.md</summary>

[uncategorized] ~79-~79: Loose punctuation mark.
Context: ...ters as the base `AMQP` class:  - `host`: RabbitMQ server hostname - `port`: Rabb...

(UNLIKELY_OPENING_PUNCTUATION)

---

[style] ~114-~114: ‘exactly the same’ might be wordy. Consider a shorter alternative.
Context: ... $password); ```  All other APIs remain exactly the same. 

(EN_WORDINESS_PREMIUM_EXACTLY_THE_SAME)

</details>

</details>
<details>
<summary>🪛 markdownlint-cli2 (0.17.2)</summary>

<details>
<summary>docs/AMQPSwoole.md</summary>

11-11: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

</details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (4)</summary>

* GitHub Check: Adapter Tests (Workerman)
* GitHub Check: Adapter Tests (Pool)
* GitHub Check: Adapter Tests (Swoole)
* GitHub Check: Adapter Tests (SwooleRedisCluster)

</details>

<details>
<summary>🔇 Additional comments (3)</summary><blockquote>

<details>
<summary>docker-compose.yml (1)</summary>

`48-58`: **LGTM! Well-structured service configuration.**

The new `amqp-swoole` service follows the established patterns and properly depends on the AMQP service health check.

</details>
<details>
<summary>docs/AMQPSwoole.md (1)</summary>

`1-114`: **Excellent comprehensive documentation.**

The documentation clearly explains the motivation for AMQPSwoole, provides practical examples, and includes a complete migration guide. This will be very helpful for users adopting the new broker.

</details>
<details>
<summary>tests/Queue/E2E/Adapter/AMQPSwooleTest.php (1)</summary>

`26-43`: **LGTM! Proper Swoole coroutine integration.**

The test correctly uses `Co\run` and `go` constructs to execute within Swoole coroutines, which is essential for testing the AMQPSwoole broker functionality.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

…umentation

- Changed the build path for the amqp-swoole service in docker-compose.yml to reflect the new directory structure.
- Deleted the AMQPSwoole.md documentation file as it is no longer needed.
- Added exchange declaration in the AMQP class to ensure proper message routing.
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

♻️ Duplicate comments (1)
docker-compose.yml (1)

137-137: Ensure newline at end of file
Add a trailing newline to satisfy YAML formatting requirements and avoid linter errors.

🧹 Nitpick comments (1)
docker-compose.yml (1)

93-93: DRY up repetitive healthcheck blocks
Each Redis cluster node and the amqp service repeats the same start_period: 0s (alongside start_interval: 1s). Consider defining a reusable YAML anchor (e.g. x-healthcheck) for common parameters to reduce duplication.

Also applies to: 104-104, 115-115, 126-126, 137-137

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 12808fd and baa8c07.

📒 Files selected for processing (4)
  • docker-compose.yml (7 hunks)
  • src/Queue/Broker/AMQP.php (3 hunks)
  • tests/Queue/E2E/Adapter/AMQPSwooleTest.php (1 hunks)
  • tests/Queue/servers/AMQPSwoole/worker.php (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/Queue/servers/AMQPSwoole/worker.php
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/Queue/Broker/AMQP.php
  • tests/Queue/E2E/Adapter/AMQPSwooleTest.php
🧰 Additional context used
🪛 YAMLlint (1.37.1)
docker-compose.yml

[error] 137-137: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Adapter Tests (Swoole)
  • GitHub Check: Adapter Tests (AMQP)
  • GitHub Check: Adapter Tests (SwooleRedisCluster)
  • GitHub Check: Adapter Tests (Pool)
🔇 Additional comments (2)
docker-compose.yml (2)

8-8: Mount phpunit configuration into test container
The new ./phpunit.xml:/usr/local/src/phpunit.xml volume ensures PHPUnit picks up the custom config (process isolation, stop-on-failure) correctly.


12-12: Include AMQPSwoole as a test dependency
Adding amqp-swoole to the tests.depends_on list guarantees that the Swoole-based broker is up before running tests.

Comment on lines +48 to +57
amqp-swoole:
container_name: amqp-swoole
build: ./tests/Queue/servers/AMQP/.
command: php /usr/src/code/tests/Queue/servers/AMQPSwoole/worker.php
volumes:
- ./src:/usr/local/src/src
- ./tests:/usr/local/src/tests
depends_on:
amqp:
condition: service_healthy
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix build context for amqp-swoole service
The amqp-swoole service currently builds from the AMQP directory but runs the Swoole worker. This will produce an incorrect image.

Apply this diff to correct the build context:

-  amqp-swoole:
-    container_name: amqp-swoole
-    build: ./tests/Queue/servers/AMQP/.
+  amqp-swoole:
+    container_name: amqp-swoole
+    build: ./tests/Queue/servers/AMQPSwoole/.
     command: php /usr/src/code/tests/Queue/servers/AMQPSwoole/worker.php
     volumes:
       - ./src:/usr/local/src/src
       - ./tests:/usr/local/src/tests
     depends_on:
       amqp:
         condition: service_healthy
📝 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.

Suggested change
amqp-swoole:
container_name: amqp-swoole
build: ./tests/Queue/servers/AMQP/.
command: php /usr/src/code/tests/Queue/servers/AMQPSwoole/worker.php
volumes:
- ./src:/usr/local/src/src
- ./tests:/usr/local/src/tests
depends_on:
amqp:
condition: service_healthy
amqp-swoole:
container_name: amqp-swoole
build: ./tests/Queue/servers/AMQPSwoole/.
command: php /usr/src/code/tests/Queue/servers/AMQPSwoole/worker.php
volumes:
- ./src:/usr/local/src/src
- ./tests:/usr/local/src/tests
depends_on:
amqp:
condition: service_healthy
🤖 Prompt for AI Agents
In docker-compose.yml around lines 48 to 57, the amqp-swoole service's build
context is incorrectly set to the AMQP directory, which does not match the
Swoole worker it runs. Update the build path to point to the AMQPSwoole
directory to ensure the correct image is built for the Swoole worker.

- Removed phpunit.xml from docker-compose volumes to streamline configuration.
- Disabled process isolation and stop on failure in phpunit.xml for improved test execution.
- Commented out unused tearDown method in AMQPSwooleTest to enhance code clarity.
- Changed the version constraint for appwrite-labs/php-amqplib in composer.json to allow for minor updates.
- Updated composer.lock to reflect the new version 0.1.1 of appwrite-labs/php-amqplib.
- Removed unnecessary exchange declaration code in the AMQP class to streamline message publishing.
@christyjacob4 christyjacob4 merged commit 3c1daeb into main Jun 24, 2025
8 checks passed
@christyjacob4 christyjacob4 deleted the feat-swoole-amqp-adapter branch June 24, 2025 18:52
@coderabbitai coderabbitai bot mentioned this pull request Jul 4, 2025
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.

2 participants