Skip to content

Commit 09b7174

Browse files
committed
Docs clarification
1 parent 4a19dcc commit 09b7174

23 files changed

+52
-112
lines changed

docs/guide/en/adapter-sync.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Synchronous Adapter
22
==================
33

4-
Run tasks synchronously in the same process. It could be used when developing and debugging an application.
4+
Run tasks synchronously in the same process. The adapter is intended for use when developing and debugging an application.
55

66
Configuration example:
77

docs/guide/en/advanced-map.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,21 @@ Use this index when you need to customize internals: custom middleware, adapters
1414

1515
- [Middleware pipelines deep dive](middleware-pipelines.md) — dispatcher lifecycle, request mutations, and per-pipeline contracts.
1616
- [Callable definitions and middleware factories](callable-definitions-extended.md) — container-aware definitions for middleware factories.
17-
- [Error handling](error-handling.md#failure-pipeline-overview) — end-to-end flow of the failure pipeline.
17+
- [Error handling](error-handling.md#failure-handling-pipeline-overview-step-by-step) — end-to-end flow of the failure pipeline.
1818
- [Custom failure middleware](error-handling.md#how-to-create-a-custom-failure-middleware) — implementing `MiddlewareFailureInterface`.
1919
- [Envelope metadata and stack reconstruction](envelopes.md#metadata-and-envelope-stacking) — stack resolution and metadata merging.
2020
- [FailureEnvelope usage](error-handling.md#failureenvelope) — retry metadata semantics.
21-
- [Handler resolver pipeline](message-handler.md#resolver-pipeline) — alternative handler lookup strategies.
21+
- [Handler resolver pipeline](message-handler.md) — alternative handler lookup strategies.
2222

2323
## Queue adapters and interoperability
2424

2525
- [Custom queue provider implementations](queue-names-advanced.md#extending-the-registry) — bespoke selection logic, tenant registries, and fallback strategies.
2626
- [Consuming messages from external systems](consuming-messages-from-external-systems.md) — contract for third-party producers.
27-
- [Adapter internals](adapter-list.md#available-adapters) — extend or swap backend adapters.
27+
- [Adapter internals](adapter-list.md) — extend or swap backend adapters.
2828

29-
## Tooling, diagnostics, and storage
29+
## Tooling and diagnostics
3030

3131
- [Yii Debug collector internals](debug-integration-advanced.md) — collector internals, proxies, and manual wiring.
32-
- [Message status storage extensions](message-status.md#extend-storage) — persisting custom metadata or drivers.
33-
- [Extending queue processes and supervisors](process-managers.md#custom-supervisors) — custom supervisor hooks and graceful shutdown integration.
3432

3533
## Internals and contribution
3634

docs/guide/en/best-practices.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ final class ProcessPaymentHandler implements MessageHandlerInterface
5353

5454
### Keep message handlers stateless
5555

56-
Avoid storing per-message state in handler properties. Handlers may be reused by the container and queue workers are often long-running processes.
56+
Avoid storing per-message state in handler properties. The container may return the same handler instance for multiple consecutive messages, so handlers should not store state between invocations. Queue workers are often long-running processes, which amplifies this issue.
5757

5858
#### Bad
5959

@@ -452,7 +452,7 @@ use Yiisoft\Queue\Cli\SignalLoop;
452452
return [
453453
SignalLoop::class => [
454454
'__construct()' => [
455-
'memorySoftLimit' => 256 * 1024 * 1024, // 200MB, lower than a hard limit of 256MB
455+
'memorySoftLimit' => 200 * 1024 * 1024, // 200MB, lower than a hard limit of 256MB
456456
],
457457
],
458458
];

docs/guide/en/callable-definitions-extended.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Callable Definitions Extended
22

3-
Callable definitions in `yiisoft/queue` are based on [native PHP callables](https://www.php.net/manual/en/language.types.callable.php) and suggest additonial ways to define a callable.
3+
Callable definitions in `yiisoft/queue` are based on [native PHP callables](https://www.php.net/manual/en/language.types.callable.php) and suggest additional ways to define a callable.
44

55
Both definition types (classic callables and new ones) allow you to use a DI container and [yiisoft/injector](https://github.com/yiisoft/injector) to resolve dependencies in a lazy way.
66
These callable definition formats are used across the package to convert configuration definitions into real callables.
@@ -16,7 +16,7 @@ As you can see in the [PHP documentation](https://www.php.net/manual/en/language
1616
// do stuff
1717
}
1818
```
19-
- **First class callable**. It's a Closure too, BTW ;) Example:
19+
- **First class callable**. It is itself a `Closure`. Example:
2020
```php
2121
$callable = trim(...);
2222
$callable2 = $this->foo(...);
@@ -30,8 +30,7 @@ As you can see in the [PHP documentation](https://www.php.net/manual/en/language
3030
$foo = new Foo();
3131
$callable = [$foo, 'bar']; // this will be called the same way as $foo->bar();
3232
```
33-
- **A class static function as a string**. I don't recommend you to use this ability, as it's non-obvious and
34-
hard to refactor, but it still exists:
33+
- **A class static function as a string**. This format is non-obvious and hard to refactor; it exists for completeness only:
3534
```php
3635
$callable = 'Foo::bar'; // this will be called the same way as Foo::bar();
3736
```
@@ -60,7 +59,7 @@ As you can see in the [PHP documentation](https://www.php.net/manual/en/language
6059

6160
Under the hood, extended callable definitions behave exactly like native callables. But there is a major difference:
6261
all the objects are instantiated automatically by a PSR-11 DI container with all their dependencies
63-
and in a lazy way (only when they are really needed).
62+
and in a lazy way (only when they are needed).
6463
Ways to define an extended callable:
6564

6665
- An object method through a class name or alias:

docs/guide/en/configuration-manual.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use Yiisoft\Queue\Middleware\Push\PushMiddlewareDispatcher;
2828
use Yiisoft\Queue\Queue;
2929
use Yiisoft\Queue\Worker\Worker;
3030

31-
// A PSR-11 container is required for dependency resolution inside middleware and handlers.
31+
// A PSR-11 container is required for resolving dependencies of middleware and handlers.
3232
// How you build it is up to you.
3333
/** @var ContainerInterface $container */
3434

@@ -81,7 +81,7 @@ $queue = new Queue(
8181
// SynchronousAdapter needs a queue reference — create it after the queue
8282
$adapter = new SynchronousAdapter($worker, $queue);
8383

84-
// Wire the adapter in (returns a new Queue instance)
84+
// Attach the adapter to the queue (returns a new Queue instance)
8585
$queue = $queue->withAdapter($adapter);
8686

8787
// Now you can push messages

docs/guide/en/console-commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ yii queue:run [queueName1 [queueName2 [...]]] --limit=100
2525
2626
## 2. Listen for queued messages and process them continuously
2727
28-
The following command launches a daemon, which infinitely consumes messages from a single queue. This command receives an optional `queueName` argument to specify which queue to listen to, defaults to the default queue name `yii-queue`.
28+
The following command launches a daemon, which infinitely consumes messages from a single queue. This command receives an optional `queueName` argument to specify which queue to listen to, defaults to the queue name `yii-queue`.
2929
3030
```sh
3131
yii queue:listen [queueName]

docs/guide/en/consuming-messages-from-external-systems.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Full example:
7070

7171
### Notes about `meta`
7272

73-
The `meta` key is a general-purpose metadata container (for example, tracing, correlation, tenant information). The consumer-side application or middleware may read, add, or override keys as needed. Populating `meta` from external producers is possible but not recommended: the accepted keys and their semantics are entirely defined by the consumer application, so any contract must be maintained manually.
73+
The `meta` key is a general-purpose metadata container (for example, tracing, correlation, tenant information). The consumer-side application or middleware may read, add, or override keys as needed. Populating `meta` from external producers is possible but not recommended: the accepted keys and their semantics are entirely defined by the consumer application, so the mapping of field names and their expected values must be maintained manually.
7474

7575
## 3. Data encoding rules
7676

@@ -84,7 +84,7 @@ If your broker stores bytes, publish the UTF-8 bytes of the JSON string.
8484

8585
## 4. Publishing to a broker: what exactly to send
8686

87-
`yiisoft/queue` itself does not define a network protocol. The exact “where” this JSON goes depends on the adapter:
87+
`yiisoft/queue` itself does not define a network protocol. The exact destination or transport for this JSON depends on the adapter:
8888

8989
- Some adapters put this JSON into the broker message **body**.
9090
- Some adapters may additionally use broker headers/attributes.

docs/guide/en/debug-integration-advanced.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ The integration is based on `Yiisoft\Queue\Debug\QueueCollector` and captures:
1414

1515
The collector is enabled by registering it in Yii Debug and wrapping tracked services with proxy implementations.
1616

17-
Out of the box (see this package's `config/params.php`), the following services are intercepted:
17+
Out of the box (see this package's `config/params.php`), the following services are wrapped:
1818

1919
- `Yiisoft\Queue\Provider\QueueProviderInterface` is wrapped with `Yiisoft\Queue\Debug\QueueProviderInterfaceProxy`. The proxy decorates returned queues with `Yiisoft\Queue\Debug\QueueDecorator` so that `push()` and `status()` calls are reported to the collector.
2020
- `Yiisoft\Queue\Worker\WorkerInterface` is wrapped with `Yiisoft\Queue\Debug\QueueWorkerInterfaceProxy` to record message processing events.
2121

22-
To see data in the debug panel you must obtain `QueueProviderInterface` and `WorkerInterface` from the DI container so that the proxies remain in effect.
22+
To see data in the debug panel, obtain `QueueProviderInterface` and `WorkerInterface` from the DI container the debug proxies are registered there and will not be active if the services are instantiated directly.
2323

2424
## Manual configuration
2525

docs/guide/en/envelopes.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ An envelope acts like the wrapped message:
1111
- `getHandlerName()` is delegated to the wrapped message.
1212
- `getData()` is delegated to the wrapped message.
1313

14-
What an envelope adds is `getMetadata()`.
14+
Envelopes modify the metadata returned by `getMetadata()` and may provide convenience methods for accessing specific metadata entries (for example, `getId()` in an ID envelope).
1515

1616
## Metadata and envelope stacking
1717

@@ -22,7 +22,7 @@ Every envelope contributes its own metadata to the resulting metadata array.
2222
When `getMetadata()` is called on an envelope, it returns:
2323

2424
- the wrapped message metadata,
25-
- plus an updated `"envelopes"` stack (previous stack + current envelope class),
25+
- plus an updated `"envelopes"` stack (previous stack + current envelope's FQCN),
2626
- plus envelope-specific metadata.
2727

2828
Because envelopes wrap other messages, multiple envelopes form a stack.
@@ -39,12 +39,12 @@ and, via `MessageInterface` inheritance, also support:
3939

4040
## Restoring envelopes from metadata
4141

42-
If metadata contains the `"envelopes"` key with an array of envelope class names, the serializer will try to rebuild the stack by wrapping the message with each envelope class in the given order.
42+
If metadata contains the `"envelopes"` key with an array of envelope class names, the serializer will try to rebuild the stack by wrapping the message with each envelope in reverse order.
4343

4444
During this process:
4545

4646
- The `"envelopes"` key is removed from the base message metadata (it is set to an empty array before creating the base message).
47-
- Each envelope class from the list is applied to the message using `EnvelopeInterface::fromMessage(...)`.
47+
- Each envelope from the list is applied to the message using `EnvelopeInterface::fromMessage(...)` in reverse order.
4848
- A value is applied only if it is a string, the class exists, and it implements `EnvelopeInterface`. Otherwise it is ignored.
4949

5050
## Built-in envelopes

docs/guide/en/error-handling.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Error handling on message processing
22

3-
Often when message handling fails, we want to retry it a couple more times or redirect it to another queue. In `yiisoft/queue` this is handled by the failure handling middleware pipeline.
3+
Often when message handling fails, we want to retry the message a couple more times or redirect it to another queue. In `yiisoft/queue` this is handled by the failure handling middleware pipeline.
44

55
## When failure handling is triggered
66

@@ -64,7 +64,7 @@ In practice, built-in middlewares handle failures by re-queueing the message (sa
6464

6565
## Configuration
6666

67-
Here below is configuration via [yiisoft/config](https://github.com/yiisoft/config) (see also [Configuration with yiisoft/config](configuration-with-config.md)). If you don't use it, you should add a middleware definition list (in the `middlewares-fail` key here) to the `FailureMiddlewareDispatcher` [by your own](configuration-manual.md). You can define different failure handling pipelines for each queue name (see [Queue names](queue-names.md)). The example below defines two different failure handling pipelines:
67+
Here below is configuration via [yiisoft/config](https://github.com/yiisoft/config) (see also [Configuration with yiisoft/config](configuration-with-config.md)). If you don't use it, you should add a middleware definition list (in the `middlewares-fail` key here) to the `FailureMiddlewareDispatcher` [yourself](configuration-manual.md). You can define different failure handling pipelines for each queue name (see [Queue names](queue-names.md)). The example below defines two different failure handling pipelines:
6868

6969
```php
7070
'yiisoft/queue' => [
@@ -114,7 +114,7 @@ In the example above failures will be handled this way (look the concrete middle
114114
3. From now on it will be resent to the same queue (`failed-messages`) up to 30 times with a delay from 5 to 60 seconds, increased 1.5 times each time the message fails again.
115115
4. If the message handler throw an exception one more (33rd) time, the exception will not be caught.
116116

117-
Failures of messages, which are initially sent to the `failed-messages` queue, will only be handled by the 3rd and the 4th points of this list.
117+
Failures of messages that arrived in the `failed-messages` queue directly (bypassing the error-handling pipeline) will only be handled by the 3rd and the 4th points of this list.
118118

119119
## Default failure handling strategies
120120

@@ -197,6 +197,6 @@ This interface has the only method `handle` with these parameters:
197197
- a [message](../../../src/Message/MessageInterface.php)
198198
- a `Throwable $exception` object thrown on the `request` handling
199199
- a queue the message came from
200-
- `MessageFailureHandlerInterface $handler` - failure strategy pipeline continuation. Your Middleware should call `$pipeline->handle()` when it shouldn't interrupt failure pipeline execution.
200+
- `MessageFailureHandlerInterface $handler` - failure strategy pipeline continuation. Your Middleware should call `$pipeline->handle()` when the middleware itself should not interrupt failure pipeline execution.
201201

202-
> Note: your strategy have to check by its own if it should be applied. Look into [`SendAgainMiddleware::suites()`](../../../src/Middleware/FailureHandling/Implementation/SendAgainMiddleware.php#L54) for an example.
202+
> Note: your strategy have to check by its own if it should be applied. Look into [`SendAgainMiddleware::suits()`](../../../src/Middleware/FailureHandling/Implementation/SendAgainMiddleware.php#L54) for an example.

0 commit comments

Comments
 (0)