Skip to content

Conversation

@viktorprogger
Copy link
Contributor

Q A
Is bugfix? ✔️
New feature?
Breaks BC?

@viktorprogger viktorprogger changed the title Start docs refining Documentation Dec 13, 2025
@codecov
Copy link

codecov bot commented Dec 13, 2025

Codecov Report

❌ Patch coverage is 83.67347% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.88%. Comparing base (493a753) to head (4fe7321).

Files with missing lines Patch % Lines
src/Worker/Worker.php 83.33% 8 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #250      +/-   ##
============================================
- Coverage     98.59%   97.88%   -0.72%     
- Complexity      356      362       +6     
============================================
  Files            47       47              
  Lines           927      945      +18     
============================================
+ Hits            914      925      +11     
- Misses           13       20       +7     

☔ 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.


- Optionally: define default `\Yiisoft\Queue\Adapter\AdapterInterface` implementation.
- And/or define channel-specific `AdapterInterface` implementations in the `channels` params key to be used
with the [queue provider](usage.md#different-queue-channels).
Copy link
Member

Choose a reason for hiding this comment

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

There's nothing in usage.md about queue provider and there's no such anchor as well.

@viktorprogger viktorprogger marked this pull request as ready for review January 7, 2026 15:19
@samdark samdark requested a review from Copilot January 7, 2026 19:50
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 pull request is marked as a bugfix and includes significant documentation improvements, code refactoring, and a critical bug fix. The main changes involve integrating CallableFactory into the Worker class to simplify handler resolution, fixing a bug in the JSON message serializer, adding comprehensive documentation, and adding a command alias.

Key changes:

  • Integration of CallableFactory into Worker for unified callable resolution
  • Bug fix in JsonMessageSerializer where $payload['meta'] was incorrectly accessed instead of $meta
  • Extensive documentation added covering queue channels, message handlers, middleware pipelines, error handling, and more
  • Command alias queue:listen-all added to replace the typo queue:listen:all

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/Unit/WorkerTest.php Added new test case for object method callable definitions and updated tests to use CallableFactory parameter
tests/Unit/Middleware/CallableFactoryTest.php Major refactoring with data providers for comprehensive testing of callable factory scenarios
tests/TestCase.php Added CallableFactory parameter to worker creation
tests/Integration/MiddlewareTest.php Added CallableFactory parameter to test setup
tests/Integration/MessageConsumingTest.php Added CallableFactory instantiation and parameter in worker setup
tests/Benchmark/QueueBench.php Added CallableFactory parameter to worker constructor
src/Worker/Worker.php Integrated CallableFactory for unified handler resolution, simplified handler caching logic
src/Middleware/CallableFactory.php Enhanced to support Closure detection, object method definitions, and improved validation
src/Message/JsonMessageSerializer.php Bug fix: corrected variable reference from $payload['meta'] to $meta
src/Command/ListenAllCommand.php Added command alias 'queue:listen:all' for backward compatibility
docs/guide/en/worker.md Rewritten to focus on starting workers and supervisor configuration
docs/guide/en/usage.md Expanded with queue channels, delayed execution, job status examples
docs/guide/en/producing-messages-from-external-systems.md New comprehensive guide for external message producers
docs/guide/en/prerequisites-and-installation.md New installation and requirements guide
docs/guide/en/middleware-pipelines.md New detailed middleware pipeline documentation
docs/guide/en/message-handler.md New guide explaining handler definition formats and configuration
docs/guide/en/loops.md New documentation on loop interface and signal handling
docs/guide/en/job-status.md New guide on job status tracking
docs/guide/en/error-handling.md Significantly expanded with step-by-step failure handling flow
docs/guide/en/envelopes.md New documentation on envelope pattern and metadata handling
docs/guide/en/debug-integration.md New guide for Yii Debug integration
docs/guide/en/console-commands.md New comprehensive console commands reference
docs/guide/en/configuration-with-config.md New configuration guide for yiisoft/config users
docs/guide/en/configuration-manual.md New manual configuration guide with examples
docs/guide/en/channels.md New detailed guide on queue channels concept and configuration
docs/guide/en/callable-definitions-extended.md New guide explaining extended callable definition formats
docs/guide/en/README.md Restructured guide index with better organization
config/params.php Added 'queue:listen-all' command alias
README.md Major rewrite with quick start guide and improved structure

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

@@ -0,0 +1,100 @@
# Callable Definitions Extended

Сallable definitions in `yiisoft/queue` extend [native PHP callables](https://www.php.net/manual/en/language.types.callable.php). That means, there are two types of definitions. Nevertheless, each of them may define dependency list in their parameter lists, which will be resolved via [yiisoft/injector](https://github.com/yiisoft/injector) and a DI Container.
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

The word "Сallable" starts with a Cyrillic character 'С' (U+0421) instead of the Latin 'C' (U+0043). This should be "Callable" with a Latin C.

Suggested change
Сallable definitions in `yiisoft/queue` extend [native PHP callables](https://www.php.net/manual/en/language.types.callable.php). That means, there are two types of definitions. Nevertheless, each of them may define dependency list in their parameter lists, which will be resolved via [yiisoft/injector](https://github.com/yiisoft/injector) and a DI Container.
Callable definitions in `yiisoft/queue` extend [native PHP callables](https://www.php.net/manual/en/language.types.callable.php). That means, there are two types of definitions. Nevertheless, each of them may define dependency list in their parameter lists, which will be resolved via [yiisoft/injector](https://github.com/yiisoft/injector) and a DI Container.

Copilot uses AI. Check for mistakes.
Comment on lines +72 to +78
You need to create a handler class that will process the queue messages. The most simple way is to implement the `HandleInterface`. Let's create an example for remote file processing:

```php
class FileDownloader
use Yiisoft\Queue\Handler\HandleInterface;
use Yiisoft\Queue\Message\MessageInterface;

final readonly class RemoteFileHandler implements HandleInterface
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

The documentation references HandleInterface but the actual interface in the codebase is MessageHandlerInterface (located at Yiisoft\Queue\Message\MessageHandlerInterface). The namespace and interface name should be corrected.

Copilot uses AI. Check for mistakes.

### Notes about `meta`

The `meta` key is used by `yiisoft/queue` for internal processing (like tracing and correlation) and should not be set by external systems.
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

The documentation states that the meta key "should not be set by external systems" on line 73, but earlier on lines 41 and 64-67 it shows meta as an optional parameter in the JSON format. This is contradictory. Either external systems can provide metadata (in which case the warning should be removed or modified), or they shouldn't (in which case the examples and format description should be updated to clarify that meta is for internal use only and will be ignored or overwritten).

Suggested change
The `meta` key is used by `yiisoft/queue` for internal processing (like tracing and correlation) and should not be set by external systems.
The `meta` key is a general-purpose metadata container (for example, tracing, correlation, tenant information). External systems may populate it, and the consumer-side application or middleware may also read, add, or override keys as needed.

Copilot uses AI. Check for mistakes.
You can declare error handling a middleware pipeline in the `FailureMiddlewareDispatcher`, either in the constructor, or in the `withMiddlewares()` method. If you use [yiisoft/config](yiisoft/config), you can add middleware to the `middlewares-fail` key of the `yiisoft/queue` array in the `params`.

See [error handling docs](docs/guide/error-handling.md) for details.
> In case you're using the `SynchronosAdapter` for development purposes, you should not use these commands, as you have no asynchronous processing available. The messages are processed immediately when pushed.
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

Typo: "SynchronosAdapter" should be "SynchronousAdapter" (missing 'u' before 's').

Suggested change
> In case you're using the `SynchronosAdapter` for development purposes, you should not use these commands, as you have no asynchronous processing available. The messages are processed immediately when pushed.
> In case you're using the `SynchronousAdapter` for development purposes, you should not use these commands, as you have no asynchronous processing available. The messages are processed immediately when pushed.

Copilot uses AI. Check for mistakes.

To use this feature, you have to create a middleware class, which implements `MiddlewarePushInterface`, and
return a modified `PushRequest` object from the `processPush` method:
By default, Yii Framework uses [yiisoft/yii-console](https://github.com/yiisoft/yii-console) to run CLI commands. If you installed [yiisoft/app](https://github.com/yiisoft/app) or [yiisoft/app-api](https://github.com/yiisoft/app-api), you can run the queue worker with on of these two commands:
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

Typo: "on of these two commands" should be "one of these two commands".

Suggested change
By default, Yii Framework uses [yiisoft/yii-console](https://github.com/yiisoft/yii-console) to run CLI commands. If you installed [yiisoft/app](https://github.com/yiisoft/app) or [yiisoft/app-api](https://github.com/yiisoft/app-api), you can run the queue worker with on of these two commands:
By default, Yii Framework uses [yiisoft/yii-console](https://github.com/yiisoft/yii-console) to run CLI commands. If you installed [yiisoft/app](https://github.com/yiisoft/app) or [yiisoft/app-api](https://github.com/yiisoft/app-api), you can run the queue worker with one of these two commands:

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,100 @@
# Callable Definitions Extended

Сallable definitions in `yiisoft/queue` extend [native PHP callables](https://www.php.net/manual/en/language.types.callable.php). That means, there are two types of definitions. Nevertheless, each of them may define dependency list in their parameter lists, which will be resolved via [yiisoft/injector](https://github.com/yiisoft/injector) and a DI Container.
Copy link
Member

Choose a reason for hiding this comment

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

The sentence isn't clear. I read it as "callable definitions extend native PHP callables so there are two types of definitions because of that".

# Callable Definitions Extended

Сallable definitions in `yiisoft/queue` extend [native PHP callables](https://www.php.net/manual/en/language.types.callable.php). That means, there are two types of definitions. Nevertheless, each of them may define dependency list in their parameter lists, which will be resolved via [yiisoft/injector](https://github.com/yiisoft/injector) and a DI Container.
It is used across the package to convert configuration definitions into real callables.
Copy link
Member

Choose a reason for hiding this comment

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

It = injector or container?


## Type 1: Native PHP callable

When you define a callable in a such manner, they are not modified in any way and are called as is. An only difference is that you can define dependency list in their parameter lists, which will be resolved via [yiisoft/injector](https://github.com/yiisoft/injector) and a DI Container.
Copy link
Member

Choose a reason for hiding this comment

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

Which "such manner"? Do you mean native PHP callable?

Copy link
Member

Choose a reason for hiding this comment

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

What are they who are not modified? Callables? Parameters?


- **Closure (lambda function)**. It may be static. Example:
```php
$callable = static function(Update $update) {
Copy link
Member

Choose a reason for hiding this comment

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

What is Update here?


## Type 2: Callable definition extensions (via container)

Under the hood, this extension behaves exactly like the **Type 1** ones. But there is a major difference too:
Copy link
Member

Choose a reason for hiding this comment

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

Which "this extension"?

Copy link
Member

Choose a reason for hiding this comment

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

What's "type 1"?

yii queue:listen-all [channel1 [channel2 [...]]] --pause=1 --maximum=0
```
> The command alias `queue:listen:all` is deprecated and will be removed in `1.0.0`, since it was a typo.
Copy link
Member

Choose a reason for hiding this comment

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

Should be removed before release. Let's create an issue for it and for the actual alias. Or we can remove it right away. There was no release yet so there's no backwards compatibility promise yet.

Comment on lines +17 to +27
## How it works

The integration is enabled by registering the collector and wrapping tracked services with proxy implementations.

In this package defaults (see `config/params.php`), the following services are tracked:

- `Yiisoft\Queue\Provider\QueueProviderInterface` is wrapped with `Yiisoft\Queue\Debug\QueueProviderInterfaceProxy`.
The proxy decorates returned queues with `Yiisoft\Queue\Debug\QueueDecorator` to collect `push()` and `status()` calls.
- `Yiisoft\Queue\Worker\WorkerInterface` is wrapped with `Yiisoft\Queue\Debug\QueueWorkerInterfaceProxy` to collect message processing.

Because of that, to see data in debug you should obtain `QueueProviderInterface` / `WorkerInterface` from the DI container.
Copy link
Member

Choose a reason for hiding this comment

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

That looks like internal info. Does the end user need to know these details? Same for many docs in the guide.

## Configuration
## When failure handling is triggered

Failure handling is triggered only when message processing throws a `Throwable`.
Copy link
Member

Choose a reason for hiding this comment

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

How about PHP notices or warnings or errors?


Let's see the built-in defaults.

### [SendAgainMiddleware](../../../src/Middleware/FailureHandling/Implementation/SendAgainMiddleware.php)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think such links will work well when rendering the guide.

try {
$handler = $this->getHandler($name);
} catch (InvalidCallableConfigurationException $exception) {
throw new RuntimeException(sprintf('Queue handler with name "%s" does not exist', $name), 0, $exception);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
throw new RuntimeException(sprintf('Queue handler with name "%s" does not exist', $name), 0, $exception);
throw new RuntimeException(sprintf('Queue handler with name "%s" does not exist.', $name), 0, $exception);

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.

4 participants