Skip to content

Divide queue and channel names#259

Open
viktorprogger wants to merge 3 commits intomasterfrom
divide-queue-and-channel-names
Open

Divide queue and channel names#259
viktorprogger wants to merge 3 commits intomasterfrom
divide-queue-and-channel-names

Conversation

@viktorprogger
Copy link
Contributor

@viktorprogger viktorprogger commented Feb 1, 2026

Q A
Is bugfix? ✔️
New feature?
Breaks BC? ✔️
Tests pass? ✔️
Fixed issues #255

@viktorprogger viktorprogger requested review from samdark and vjik February 1, 2026 16:52
@viktorprogger viktorprogger marked this pull request as draft February 1, 2026 16:53
@viktorprogger viktorprogger marked this pull request as ready for review February 7, 2026 11:02
@codecov
Copy link

codecov bot commented Feb 7, 2026

Codecov Report

❌ Patch coverage is 98.57143% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.60%. Comparing base (4508fbe) to head (f5783a2).

Files with missing lines Patch % Lines
src/Debug/QueueCollector.php 75.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #259      +/-   ##
============================================
- Coverage     98.62%   98.60%   -0.03%     
+ Complexity      356      351       -5     
============================================
  Files            47       46       -1     
  Lines           948      933      -15     
============================================
- Hits            935      920      -15     
  Misses           13       13              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR separates logical queue names from adapter-specific channel configuration by removing channel-related methods from AdapterInterface and updating the queue/provider APIs accordingly (per #255). It updates config keys/CLI commands/tests to use queue names, and introduces a small normalizer utility for enum-backed queue names.

Changes:

  • Remove withChannel() / getChannel() from AdapterInterface; introduce queue naming via QueueInterface::getName() and QueueInterface::withAdapter(..., $queueName).
  • Replace Channel* concepts with Queue* in providers/exceptions/config/CLI, and add QueueNameNormalizer.
  • Update stubs, debug tooling, and tests to align with the new queue-name API.

Reviewed changes

Copilot reviewed 41 out of 41 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/Unit/WorkerTest.php Switch failure pipeline lookup to use queue name (getName()).
tests/Unit/Stubs/StubQueueTest.php Remove getChannel()-without-adapter test (API removed).
tests/Unit/QueueTest.php Update queue naming expectations to getName() and new withAdapter() signature.
tests/Unit/Provider/QueueNotFoundExceptionTest.php Rename exception test to queue-based concept and adjust assertions.
tests/Unit/Provider/PrototypeQueueProviderTest.php Remove tests for deleted PrototypeQueueProvider.
tests/Unit/Provider/CompositeQueueProviderTest.php Update provider tests to assert getName() and new exception class.
tests/Unit/Provider/AdapterFactoryQueueProviderTest.php Update provider tests for queue names; add coverage for queue-name vs adapter-channel separation.
tests/Unit/Middleware/Push/MiddlewareDispatcherTest.php Adjust middleware tests to work with removed adapter interface channel methods.
tests/Unit/Debug/QueueDecoratorTest.php Update decorator test from getChannel() to getName().
tests/Unit/Command/RunCommandTest.php Expand/adjust command tests for queue-name arguments and output text.
tests/Unit/Command/ListenCommandTest.php Update listen command tests for default/custom queue argument behavior.
tests/Unit/Adapter/SynchronousAdapterTest.php Remove channel-related adapter tests after interface change.
tests/Integration/MiddlewareTest.php Update integration wiring to include queue name and use getName().
tests/Benchmark/Support/VoidAdapter.php Remove withChannel() implementation from benchmark adapter (interface no longer requires it).
tests/Benchmark/QueueBench.php Use named argument to pass adapter after constructor signature change.
tests/App/FakeAdapter.php Update normalizer usage and adjust withChannel() return type to self.
tests/App/DummyQueue.php Update queue naming ($name, getName()) and withAdapter() signature.
stubs/StubQueue.php Add queue name state and support setting it via withAdapter(..., $queueName).
stubs/StubAdapter.php Swap normalizer and default constant; keep adapter-local channel behavior for tests.
src/QueueNameNormalizer.php New internal helper to normalize `string
src/QueueInterface.php Introduce queue naming API (getName()) and update withAdapter() signature.
src/Queue.php Store logical queue name; getName() returns it; withAdapter() can set it.
src/Provider/QueueProviderInterface.php Rename defaults and API params from channel to queue name.
src/Provider/QueueNotFoundException.php New exception replacing ChannelNotFoundException.
src/Provider/PrototypeQueueProvider.php Remove provider that depended on adapter channel mutation.
src/Provider/CompositeQueueProvider.php Use queue-name terminology and throw QueueNotFoundException.
src/Provider/ChannelNotFoundException.php Remove channel-specific exception class.
src/Provider/AdapterFactoryQueueProvider.php Create queues by setting queue name on queue rather than mutating adapter channel.
src/Middleware/FailureHandling/FailureMiddlewareDispatcher.php Select failure middleware pipeline by queue name instead of channel.
src/Debug/QueueProviderInterfaceProxy.php Update proxy method params from channel to queue name.
src/Debug/QueueDecorator.php Collect debug info using queue name; update withAdapter() signature.
src/Debug/QueueCollector.php Store pushes/processing messages keyed by queue name.
src/Command/RunCommand.php Rename CLI argument to queue and adjust messages/options wording.
src/Command/ListenCommand.php Rename CLI argument to queue and update default constant usage.
src/Command/ListenAllCommand.php Rename CLI argument to queue and update help text.
src/ChannelNormalizer.php Remove old channel normalizer (replaced by queue name normalizer).
src/Adapter/SynchronousAdapter.php Remove channel state and channel-mutating methods.
src/Adapter/AdapterInterface.php Remove channel-related methods from the adapter interface.
config/params.php Rename config key channelsqueues and default constant.
config/di.php Wire providers/commands using the new queues params key.
README.md Update adapter definition examples (but still needs further alignment with queue-name terminology/API).
Comments suppressed due to low confidence (1)

tests/Unit/Provider/QueueNotFoundExceptionTest.php:28

  • This test was loosened to assertStringContainsString(), which may hide regressions in the exception message format. Since QueueNotFoundException has a deterministic message, prefer asserting the full message (and consider renaming $expectedChannel/$channel to queue-oriented names for clarity).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +44 to +50
/**
* @param AdapterInterface $adapter Adapter to use.
* @param string|null $queueName Queue name to use.
*
* @return static A new queue with the given adapter and queue name.
*/
public function withAdapter(AdapterInterface $adapter, string|BackedEnum|null $queueName = null): static;
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

PHPDoc for withAdapter() says @param string|null $queueName, but the signature accepts string|BackedEnum|null. Update the docblock to include BackedEnum (and ensure wording matches the new queue-name concept).

Copilot uses AI. Check for mistakes.
throw new InvalidQueueConfigException(
sprintf(
'Adapter must implement "%s". For channel "%s" got "%s" instead.',
'Adapter must implement "%s". For queueName "%s" got "%s" instead.',
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

The error message uses the term queueName (camelCase) in user-facing text: For queueName "%s" .... Consider changing it to a more readable phrase such as "For queue "%s"" or "For queue name "%s"" and update the related test expectation accordingly.

Suggested change
'Adapter must implement "%s". For queueName "%s" got "%s" instead.',
'Adapter must implement "%s". For queue "%s" got "%s" instead.',

Copilot uses AI. Check for mistakes.
Comment on lines +136 to +139
/** @var StubQueue $mailQueue<StubAdapter> */
$mailQueue = $provider->get('mail-queue');
/** @var StubQueue $logQueue<StubAdapter> */
$logQueue = $provider->get('log-queue');
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

These PHPDoc annotations have invalid generic syntax: /** @var StubQueue $mailQueue<StubAdapter> */. For Psalm-style generics, the generic should be on the type, e.g. StubQueue<StubAdapter>, not appended to the variable name.

Copilot uses AI. Check for mistakes.
Comment on lines 186 to 191
[
'channel1' => new SynchronousAdapter(),
'channel2' => static fn(SynchronousAdapter $adapter) => $adapter->withChannel('channel2'),
'channel3' => [
'channel2' => new SynchronousAdapter(), // a second instance for a different queue processing pipeline
'channel3' => [ // use a yiisoft/factory syntax for adapter creation
'class' => SynchronousAdapter::class,
'__constructor' => ['channel' => 'channel3'],
],
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

The adapter-definition example still uses channel1/channel2/channel3 keys and instantiates SynchronousAdapter without required constructor dependencies. Since this PR switches terminology to queue names and removes adapter channel configuration from the interface, this snippet should be updated to reflect the new API (queue names) and a realistic adapter construction/definition example.

Copilot uses AI. Check for mistakes.
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.

3 participants