protected function ZeroConfigPurger::getResultsConcurrently in Varnish purger 8.2
Concurrently execute the given requests.
Parameters
string $caller: Name of the PHP method that is executing the requests.
\Closure $requests: Generator yielding requests which will be passed to \GuzzleHttp\Pool.
Return value
array An array of invalidation response statuses. Each key is a result ID, containing an array of booleans representing if each request succeeded or failed.
3 calls to ZeroConfigPurger::getResultsConcurrently()
- ZeroConfigPurger::invalidateTags in src/
Plugin/ Purge/ Purger/ ZeroConfigPurger.php - Invalidate a set of tag invalidations.
- ZeroConfigPurger::invalidateUrls in src/
Plugin/ Purge/ Purger/ ZeroConfigPurger.php - Invalidate a set of URL invalidations.
- ZeroConfigPurger::invalidateWildcardUrls in src/
Plugin/ Purge/ Purger/ ZeroConfigPurger.php - Invalidate URLs that contain the wildcard character "*".
File
- src/
Plugin/ Purge/ Purger/ ZeroConfigPurger.php, line 172
Class
- ZeroConfigPurger
- A purger with minimal configuration required.
Namespace
Drupal\varnish_purger\Plugin\Purge\PurgerCode
protected function getResultsConcurrently($caller, $requests) {
$this
->debug(__METHOD__);
$results = [];
// Create a concurrently executed Pool which collects a boolean per request.
$pool = new Pool($this->client, $requests(), [
'options' => $this
->getGlobalOptions(),
'concurrency' => self::CONCURRENCY,
'fulfilled' => function ($response, $result_id) use (&$results) {
/** @var \Drupal\purge\Logger\LoggerChannelPartInterface|null $logger */
$logger = $this
->logger();
if ($logger
->isDebuggingEnabled()) {
$this
->debug(__METHOD__ . '::fulfilled');
$this
->logDebugTable($this
->debugInfoForResponse($response));
}
$results[$result_id][] = TRUE;
},
'rejected' => function ($reason, $result_id) use (&$results, $caller) {
$this
->debug(__METHOD__ . '::rejected');
$this
->logFailedRequest($caller, $reason);
$results[$result_id][] = FALSE;
},
]);
// Initiate the transfers and create a promise.
$promise = $pool
->promise();
// Force the pool of requests to complete.
$promise
->wait();
$this
->debug(__METHOD__);
return $results;
}