You are here

public function SolrConnectorPluginBase::adjustTimeout in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::adjustTimeout()
  2. 8.2 src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::adjustTimeout()

Sets a new timeout for queries, but not for indexing or optimization.

The timeout will not be saved in the configuration of the connector. It will be overwritten for the current request only.

Parameters

int $seconds: The new query timeout value to set.

string $timeout: (optional) The configured timeout to use. Default is self::QUERY_TIMEOUT.

\Solarium\Core\Client\Endpoint|null $endpoint: (optional) The Solarium endpoint object.

Return value

int The previous query timeout value.

Overrides SolrConnectorInterface::adjustTimeout

File

src/SolrConnector/SolrConnectorPluginBase.php, line 1065

Class

SolrConnectorPluginBase
Defines a base class for Solr connector plugins.

Namespace

Drupal\search_api_solr\SolrConnector

Code

public function adjustTimeout(int $seconds, string $timeout = self::QUERY_TIMEOUT, ?Endpoint &$endpoint = NULL) : int {
  $this
    ->connect();
  if (!$endpoint) {
    $endpoint = $this->solr
      ->getEndpoint();
  }
  $previous_timeout = $endpoint
    ->getOption($timeout);
  $options = $endpoint
    ->getOptions();
  $options[$timeout] = $seconds;
  $endpoint = new Endpoint($options);
  return $previous_timeout;
}