You are here

function _acquia_purge_diagnostics_queue_safety in Acquia Purge 7

Queue safety.

Parameters

string $t: Name of the t() function to call.

AcquiaPurgeService $service: The Acquia Purge service.

Return value

array Associative array with the following elements:

1 string reference to '_acquia_purge_diagnostics_queue_safety'
acquia_purge_acquia_purge_diagnostics in ./acquia_purge.module
Implements hook_acquia_purge_diagnostics().

File

./acquia_purge.diagnostics.inc, line 936
Diagnostic self-tests and reports that aim to prevent runtime misery.

Code

function _acquia_purge_diagnostics_queue_safety($t, $service) {
  $qitems = $service
    ->stats()['remaining'];

  // Define the warning and shutdown thresholds and setup $test.
  $factor = $service
    ->capacity()
    ->httpRequestsFactor();
  $warning = ceil(3000 / $factor);
  $shutdown = ceil(10000 / $factor);
  $tvars = array(
    '@qitems' => $qitems,
    '@warning' => $warning,
    '@shutdown' => $shutdown,
  );
  $test = array(
    'title' => $t('Queue safety'),
    'value' => $t('Warning at @warning, shutdown at @shutdown items', $tvars),
  );

  // Test the queue level for these thresholds and act appropriately.
  if ($qitems < $warning) {
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_OK;
  }
  elseif ($qitems >= $warning && $qitems < $shutdown) {
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_WARNING;
    $test['description'] = $t('Your queue holds @qitems items now which is' . ' regarded as dangerous, as it either means that your are clearing too' . ' broadly (domains, http:// and https://) or that your installation is' . ' not able to keep up processing. If you are not using cron for' . ' processing, consider this now and if you already are, consider a' . ' shorter cron interval. If you have many domain names, consider' . ' reducing the domains. As safety measure, Acquia Purge will shut' . ' itself down once the queue reaches @shutdown items!', $tvars);
  }
  elseif (_acquia_purge_variable('acquia_purge_allriskmode') && $qitems >= $shutdown) {
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_WARNING;
    $test['description'] = $t('Your queue contains @qitems items and crossed' . ' the safety limit of @shutdown items, Acquia Purge has not shut itself' . ' down because you enabled "all risk mode". Because of this, you are' . ' not entitled to Acquia support for any tickets related to queue' . ' processing. You are being highly encouraged to lower your slowdown' . ' factor by reducing domain names and/or increasing your cron interval' . ' or enable cron processing when you have not yet done this.', $tvars);
  }
  elseif ($qitems >= $shutdown) {
    $test['severity'] = ACQUIA_PURGE_SEVLEVEL_ERROR;
    $test['description'] = $t('Your queue contains @qitems items and crossed' . ' the safety limit of @shutdown items, Acquia Purge has shut itself' . ' down to prevent your system from thrashing. What this means is that' . ' you are either clearing too broadly (domains, http:// and https://)' . ' or that your installation is not able to keep up. If you are not' . ' using cron for processing, set this up now and if you already are,' . ' increase your cron interval! If you have many domain names, reduce' . ' the list. Clear Varnish manually and run drush ap-forget to clear' . ' your queue and unblock the safety shutdown.', $tvars);
  }
  return $test;
}