私はguzzle php versionを使用しています:6.2.2。 Promiseが実行されている経過時間を送信することは、以下のコードで可能ですか?例えば。 5秒ごとに、経過時間を関数に送信しますか?例えば同時のGuzzle Promiseプールの経過時間を取得する方法
$client = new Client([
'base_uri' => BASE_URL . 'sync/import', // Base URI is used with relative requests
'timeout' => 0, // 0 no timeout for operations and watching Promises
'verify' => true
]);
$requests = function ($syncRequests) {
foreach ($syncRequests as $key => $headers) {
yield new Request('PUT', '', ['Content-type' => 'application/json'], json_encode(['json' => ['sync' => $headers]]));
}
};
$pool = new Pool($client, $requests($this->syncRequests), [
'concurrency' => 10,
'fulfilled' => function ($response, $index) {
$this->promiseFulfilled($response, $index);
},
'rejected' => function ($reason, $index) {
$this->promiseRejected($reason, $index);
},
]);
$promise = $pool->promise(); // Initiate the transfers and create a promise
$promise->wait(); // Force the pool of requests to complete.
:
$pool = new Pool($client, $requests($this->syncRequests), [
'concurrency' => 10,
'while' => function() { // CALLED WHILE THE CONCURRENT REQUESTS ARE RUNNING!!
$this->elapsedTime();
},
'fulfilled' => function ($response, $index) {
$this->promiseFulfilled($response, $index);
},
'rejected' => function ($reason, $index) {
$this->promiseRejected($reason, $index);
},
]);
Nadir、同時リクエストが処理中の「while」という関数を呼び出す方法はありますか?私は "達成された"ときに私は任意の機能を呼び出すことができる知っているが、私はプールが実行されている経過時間を取得する "while"要求が実行されている。 – Zelf