Split queue consumer contract - #321
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #321 +/- ##
========================================
Coverage 0.00% 0.00%
- Complexity 322 380 +58
========================================
Files 51 54 +3
Lines 901 1000 +99
========================================
- Misses 901 1000 +99 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR splits message production vs consumption responsibilities by removing run() / listen() from QueueInterface and introducing a dedicated QueueConsumerInterface, then updates the core queue implementation, debug decorators, console commands, tests, benchmarks, and docs to match the new contracts (Fixes #320).
Changes:
- Introduce
QueueConsumerInterface(run()/listen()) and remove those methods fromQueueInterface. - Update
Queue, stub queue, debug provider proxy/decorators, and console commands to preserve producer-only vs consumer-capable queue contracts. - Update unit tests, benchmarks, and documentation to reflect the split.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/QueueTest.php | Adds contract assertions for producer vs consumer interfaces. |
| tests/Unit/Debug/QueueProviderInterfaceProxyTest.php | Verifies consumer-capable queues are decorated with the consumer decorator. |
| tests/Unit/Debug/QueueDecoratorTest.php | Updates tests to use the new consumer decorator for run()/listen(). |
| tests/Unit/Command/RunCommandTest.php | Updates mocks to use the consumer interface and adds validation test for producer-only queues. |
| tests/Unit/Command/ListenCommandTest.php | Updates mocks to use the consumer interface and adds validation test for producer-only queues. |
| tests/Unit/Command/ListenAllCommandTest.php | Updates mocks to use the consumer interface and adds validation test for producer-only queues. |
| tests/Benchmark/QueueBench.php | Updates benchmark typing/usage after contract split. |
| stubs/StubQueue.php | Makes the stub queue implement the new consumer contract. |
| src/QueueInterface.php | Removes run() / listen() from the producer-facing interface. |
| src/QueueConsumerInterface.php | Adds the new consumer interface with run() / listen(). |
| src/Queue.php | Declares Queue implements both producer and consumer interfaces. |
| src/Debug/QueueProviderInterfaceProxy.php | Returns consumer decorator when the queue supports consumption. |
| src/Debug/QueueDecorator.php | Removes consumption methods from the producer-only debug decorator. |
| src/Debug/QueueConsumerDecorator.php | Adds a decorator that preserves both producer and consumer contracts. |
| src/Command/RunCommand.php | Enforces that selected queues implement QueueConsumerInterface. |
| src/Command/ListenCommand.php | Enforces that selected queues implement QueueConsumerInterface. |
| src/Command/ListenAllCommand.php | Enforces that selected queues implement QueueConsumerInterface. |
| README.md | Documents producer vs consumer interfaces at a high level. |
| docs/guide/en/queue-names-advanced.md | Notes that consumer-capable queues implement QueueConsumerInterface. |
| docs/guide/en/configuration-manual.md | Updates manual configuration docs to use QueueConsumerInterface for consumption. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * This interface complements {@see QueueInterface}, which is responsible for producing messages and checking their | ||
| * status. | ||
| */ | ||
| interface QueueConsumerInterface |
There was a problem hiding this comment.
What about QueueProviderInterface? If we split queue into two interfaces, then other abstractions should work with them accordingly.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 82 out of 82 changed files in this pull request and generated no new comments.
Suppressed comments (8)
src/Provider/CompositeQueueProvider.php:81
- Code style:
}andreturnare on the same line. This is inconsistent with the rest of the codebase and is likely to fail PSR-12 / fixer rules.
src/Provider/CompositeQueueProvider.php:62 - Code style: closing brace and
returnare on the same line, which is inconsistent with the rest of the codebase and can break code-style checks.
src/Provider/CompositeQueueProvider.php:94 - Code style: closing brace and
returnare on the same line, which is inconsistent with the rest of the codebase and can break code-style checks.
src/QueueProducer.php:65 - Log message grammar: "ID doesn't assigned" is ungrammatical and can be confusing in logs. Use "ID wasn't assigned" (or similar).
src/Middleware/FailureHandling/Implementation/ExponentialDelayMiddleware.php:43 - Typo in exception message: "less then" should be "less than".
tests/Unit/Middleware/Consume/ConsumeRequestTest.php:18 $queuemock is unused (andQueueProducerInterfaceimport becomes unused). This adds noise and can trigger static analysis warnings.
src/Provider/CompositeQueueProvider.php:49- Code style:
}andreturnare on the same line. This is inconsistent with the rest of the codebase and is likely to fail PSR-12 / fixer rules.
This issue also appears in the following locations of the same file:
- line 58
- line 77
- line 91
src/Debug/QueueProducerDecorator.php:27
debug_backtrace()without flags captures arguments and the whole stack, which is unnecessarily expensive for a debug decorator. Also the current formatting puts statements on the same line as{, which is hard to read and may fail code style checks.
public function status(string|int $id): MessageStatus
{ /** @psalm-var array{file: string, line: int} $stack */ $stack = debug_backtrace()[0];
$result = $this->queue->status($id);
$this->collector->collectStatus((string) $id, $result, $stack['file'] . ':' . $stack['line']);
return $result;
Fixes #320