Предположим, мы отправляем 10 запросов одновременно, некоторые из них возвращают ответ OK (200), а некоторые - 500 (некоторые ошибки). Я новичок в жрете. Могу ли я узнать, есть ли способ сопоставить ответ с запросом, поскольку это пул запросов?
$client = new Client();
$requests = function ($total) {
$uri = 'http://127.0.0.1:8126/guzzle-server/perf';
for ($i = 0; $i < $total; $i++) {
yield new Request('GET', $uri);
}
};
$pool = new Pool($client, $requests(100), [
'concurrency' => 5,
'fulfilled' => function (Response $response, $index) {
// this is delivered each successful response
**// but how to we get to know for which request this is the response**
},
'rejected' => function (RequestException $reason, $index) {
// this is delivered each failed request
},
]);
// Initiate the transfers and create a promise
$promise = $pool->promise();
// Force the pool of requests to complete.
$promise->wait();