protected function AcquiaCloudPurger::getResultsConcurrently in Acquia Purge 8
Concurrently execute the given requests.
Parameters
\Closure $requests: Generator yielding requests which will be passed to \GuzzleHttp\Pool.
3 calls to AcquiaCloudPurger::getResultsConcurrently()
- AcquiaCloudPurger::invalidateTags in src/
Plugin/ Purge/ Purger/ AcquiaCloudPurger.php - Invalidate a set of tag invalidations.
- AcquiaCloudPurger::invalidateUrls in src/
Plugin/ Purge/ Purger/ AcquiaCloudPurger.php - Invalidate a set of URL invalidations.
- AcquiaCloudPurger::invalidateWildcardUrls in src/
Plugin/ Purge/ Purger/ AcquiaCloudPurger.php - Invalidate URLs that contain the wildcard character "*".
File
- src/
Plugin/ Purge/ Purger/ AcquiaCloudPurger.php, line 142
Class
- AcquiaCloudPurger
- Acquia Cloud.
Namespace
Drupal\acquia_purge\Plugin\Purge\PurgerCode
protected function getResultsConcurrently(\Closure $requests) {
$this
->debugger()
->callerAdd(__METHOD__);
$results = [];
// Create a concurrently executed Pool which collects a boolean per request.
$pool = new Pool($this->httpClient, $requests(), [
'options' => $this
->getGlobalOptions(),
'concurrency' => self::CONCURRENCY,
'fulfilled' => function ($response, $result_id) use (&$results) {
$this
->debugger()
->callerAdd(__METHOD__ . '::fulfilled');
$results[$result_id][] = TRUE;
$this
->debugger()
->callerRemove(__METHOD__ . '::fulfilled');
},
'rejected' => function ($exception, $result_id) use (&$results) {
$this
->debugger()
->callerAdd(__METHOD__ . '::rejected');
$this
->debugger()
->logFailedRequest($exception);
$results[$result_id][] = FALSE;
$this
->debugger()
->callerRemove(__METHOD__ . '::rejected');
},
]);
// Initiate the transfers and create a promise.
$promise = $pool
->promise();
// Force the pool of requests to complete.
$promise
->wait();
$this
->debugger()
->callerRemove(__METHOD__);
return $results;
}