Remove QueueInterface::withAdapter() and AdapterFactoryQueueProvider#266
Remove QueueInterface::withAdapter() and AdapterFactoryQueueProvider#266
QueueInterface::withAdapter() and AdapterFactoryQueueProvider#266Conversation
vjik
commented
Apr 2, 2026
| Q | A |
|---|---|
| Is bugfix? | ❌ |
| New feature? | ❌ |
| Breaks BC? | ✔️ |
| Tests pass? | ✔️ |
QueueInterface::withAdapter()QueueInterface::withAdapter() and AdapterFactoryQueueProvider
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #266 +/- ##
============================================
- Coverage 98.59% 98.51% -0.09%
+ Complexity 372 354 -18
============================================
Files 48 46 -2
Lines 998 942 -56
============================================
- Hits 984 928 -56
Misses 14 14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR removes the queue “adapter injection” API (QueueInterface::withAdapter()), deletes the AdapterFactoryQueueProvider, and updates queue construction and push flow to assume an adapter is always present.
Changes:
- Removed
QueueInterface::withAdapter()and madeQueuerequire anAdapterInterfacevia constructor. - Removed
AdapterFactoryQueueProviderandAdapterNotConfiguredException, simplifying adapter configuration and error handling. - Updated middleware/push request flow and unit/integration tests to use non-null adapters and new queue construction patterns.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/QueueInterface.php |
Removes withAdapter() from the public queue interface. |
src/Queue.php |
Makes adapter mandatory (constructor) and removes adapter-not-configured checks and withAdapter(). |
src/Middleware/Push/PushRequest.php |
Makes adapter non-nullable in push requests; updates getter signature. |
src/Middleware/Push/AdapterPushHandler.php |
Removes “no adapter” exception path; always pushes via request adapter. |
src/Debug/QueueDecorator.php |
Drops withAdapter() passthrough now that the interface no longer defines it. |
src/Provider/AdapterFactoryQueueProvider.php |
Deletes the provider that built queues from adapter definitions. |
src/Exception/AdapterConfiguration/AdapterNotConfiguredException.php |
Deletes the exception that was thrown when using a queue without an adapter. |
stubs/StubQueue.php |
Removes withAdapter() support and simplifies stub implementation accordingly. |
tests/TestCase.php |
Updates queue factory helper to construct Queue with an adapter and name. |
tests/Unit/QueueTest.php |
Reworks tests to use createQueue($adapter) instead of withAdapter(). |
tests/Unit/Stubs/StubQueueTest.php |
Removes withAdapter() test coverage from stub queue tests. |
tests/Unit/Provider/AdapterFactoryQueueProviderTest.php |
Deletes tests for removed AdapterFactoryQueueProvider. |
tests/Unit/Middleware/Push/Implementation/IdMiddlewareTest.php |
Updates PushRequest instantiation to pass a non-null adapter. |
tests/Unit/Middleware/Push/AdapterPushHandlerTest.php |
Removes test expecting exception when adapter is missing. |
tests/Unit/Debug/QueueDecoratorTest.php |
Removes decorator withAdapter() tests now that method is gone. |
tests/Unit/Adapter/SynchronousAdapterTest.php |
Refactors adapter tests to instantiate SynchronousAdapter directly without queue withAdapter(). |
tests/Integration/MiddlewareTest.php |
Updates Queue constructor argument order (adapter before name). |
tests/App/DummyQueue.php |
Removes withAdapter() from dummy queue implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
viktorprogger
left a comment
There was a problem hiding this comment.
The functional changes are ok for me, but in config we should provide reasonable defaults for these cases:
- Super simple: get a default queue with DI and make a push/listen.
- Named queues: provide a default way to define and get named queues.
| ? $container->get(SignalLoop::class) | ||
| : $container->get(SimpleLoop::class); | ||
| }, | ||
| QueueInterface::class => Queue::class, |
There was a problem hiding this comment.
It is assumed that the queue or queue provider will be configured in the container configuration in the application.
| 'queues' => [ | ||
| QueueProviderInterface::DEFAULT_QUEUE => AdapterInterface::class, | ||
| ], |
There was a problem hiding this comment.
How to configure queues with this change?
There was a problem hiding this comment.
It is assumed that the queue provider will be configured in the container configuration in the application.
| 'definitions' => $params['yiisoft/queue']['queues'], | ||
| ], | ||
| ], | ||
| QueueProviderInterface::class => AdapterFactoryQueueProvider::class, |
There was a problem hiding this comment.
Why? How to get a named queue now?
There was a problem hiding this comment.
It is assumed that the queue provider will be configured in the container configuration in the application.
src/Queue.php
Outdated
| private readonly LoopInterface $loop, | ||
| private readonly LoggerInterface $logger, | ||
| private readonly PushMiddlewareDispatcher $pushMiddlewareDispatcher, | ||
| private readonly AdapterInterface $adapter, |
There was a problem hiding this comment.
Since we're moving it, let's move it to the first place.
stubs/StubQueue.php
Outdated
| @@ -24,13 +22,12 @@ final class StubQueue implements QueueInterface | |||
| */ | |||
| public function __construct( | |||
| private ?AdapterInterface $adapter = null, | |||
There was a problem hiding this comment.
Since the QueueInterface provides no adapter knowledge, let's completely remove $adapter from this class and the corresponding tests.