You are here

public function AcquiaPurgeCapacity::queueClaimsLimit in Acquia Purge 7

Get the number of queue items that can be processed during runtime.

Return value

int The number of queue items that can be processed during runtime.

1 call to AcquiaPurgeCapacity::queueClaimsLimit()
AcquiaPurgeCapacity::queueClaimsSubtract in lib/AcquiaPurgeCapacity.php
Subtract processed queue claims from the claim limit.

File

lib/AcquiaPurgeCapacity.php, line 176
Contains AcquiaPurgeCapacity.

Class

AcquiaPurgeCapacity
Runtime capacity tracker.

Code

public function queueClaimsLimit() {
  if (is_null($this->queueClaimsLimit)) {
    $requests_per_item = $this
      ->httpRequestsFactor();
    $max_requests = $this
      ->httpRequestsLimit();

    // Divide the HTTP request limit through the number of HTTP requests
    // expected to be made for a single queue item (for a rough indication).
    $this->queueClaimsLimit = intval($max_requests / $requests_per_item);

    // Some tragically configured environments - usually those picking up a
    // lot of domain names - will dive below 1. Set a minimum for these cases.
    if ($this->queueClaimsLimit < 1) {
      $this->queueClaimsLimit = 1;
    }

    // Don't exceed the overall limit of queue claims.
    if ($this->queueClaimsLimit > self::QUEUE_CLAIMS_LIMIT) {
      $this->queueClaimsLimit = self::QUEUE_CLAIMS_LIMIT;
    }
  }
  return $this->queueClaimsLimit;
}