-
-
Notifications
You must be signed in to change notification settings - Fork 27
Documentation #250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Documentation #250
Conversation
viktorprogger
commented
Dec 13, 2025
| Q | A |
|---|---|
| Is bugfix? | ✔️ |
| New feature? | ❌ |
| Breaks BC? | ❌ |
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
|
|
||
| - 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). |
There was a problem hiding this comment.
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.
Co-authored-by: Alexander Makarov <[email protected]>
Co-authored-by: Alexander Makarov <[email protected]>
There was a problem hiding this 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
CallableFactoryintoWorkerfor unified callable resolution - Bug fix in
JsonMessageSerializerwhere$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-alladded to replace the typoqueue: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. | |||
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
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.
| С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. |
| 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 |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
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.
|
|
||
| ### 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. |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
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).
| 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. |
| 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. |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
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').
| > 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. |
|
|
||
| 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: |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
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".
| 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: |
| @@ -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. | |||
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which "this extension"?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
| ## 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. |
There was a problem hiding this comment.
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`. |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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); |