docs: rewrite JsonRpcBundle docs, add SDK docs, move them under docs/api
uk/docs/api/json-rpc-bundle/functionality/events/async_output.md
новий файл +75
−0
1
+
# rpc.async_output
2
+
3
+
::::::block class="floatinginfobox floatinginfobox--fit"
4
+
:::::columns border zebra
5
+
::::row
6
+
:::col width="40%"
7
+
**Назва події**
8
+
:::
9
+
:::col
10
+
`rpc.async_output`
11
+
:::
12
+
::::
13
+
::::row
14
+
:::col width="40%"
15
+
**Константа**
16
+
:::
17
+
:::col
18
+
`RpcEvent::OUTPUT_ASYNC`
19
+
:::
20
+
::::
21
+
::::row
22
+
:::col width="40%"
23
+
**Клас**
24
+
:::
25
+
:::col
26
+
`RpcAsyncOutputEvent`
27
+
:::
28
+
::::
29
+
::::row
30
+
:::col width="40%"
31
+
**Властивості**
32
+
:::
33
+
:::col
34
+
`RpcRequest $rpcRequest`, `RpcBatchRequest $batchRequest`, `string $output`
35
+
:::
36
+
::::
37
+
:::::
38
+
::::::
39
+
40
+
Генерується в **батьківському** процесі [batch](/docs/api/json-rpc-bundle/functionality/batch) у процесному режимі (`batch.process: true`), коли дочірній процес `ufo:rpc:process` завершився. `$output` — сирий вивід процесу (JSON відповіді).
41
+
42
+
**Не генерується** в inline-режимі batch і для одиночних запитів.
43
+
44
+
## Вбудовані лістенери
45
+
46
+
| Пріоритет | Лістенер | Що робить |
47
+
| --- | --- | --- |
48
+
| 10 | `AsyncServerEventListener::process` | Розбирає `$output` у відповідь (порожній або невалідний вивід — помилка), додає її в batch і **завжди зупиняє поширення** |
49
+
50
+
## Що можна змінити
51
+
52
+
* Лістенер з пріоритетом **вище 10** може змінити `$event->output` до розбору.
53
+
* Лістенери з пріоритетом 10 і нижче не викликаються.
54
+
* Не зупиняйте поширення вище 10: елемент не отримає відповіді й, найімовірніше, зникне з результату batch.
55
+
56
+
## Приклади використання
57
+
58
+
* діагностика: логування сирого виводу дочірніх процесів, щоб знайти причину «Asynchronous request does not respond»;
59
+
* метрики тривалості й розміру відповідей елементів batch.
60
+
61
+
```php
62
+
#[AsEventListener(RpcEvent::OUTPUT_ASYNC, priority: 100)]
63
+
final class BatchOutputLogger
64
+
{
65
+
public function __construct(private LoggerInterface $logger) {}
66
+
67
+
public function __invoke(RpcAsyncOutputEvent $event): void
68
+
{
69
+
$this->logger->debug('batch item output', [
70
+
'method' => $event->rpcRequest->getMethod(),
71
+
'bytes' => strlen($event->output),
72
+
]);
73
+
}
74
+
}
75
+
```