You are here

public function SolrConnectorPluginBase::adjustTimeout in Search API Solr 8.3

Same name and namespace in other branches
  1. 8.2 src/SolrConnector/SolrConnectorPluginBase.php \Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase::adjustTimeout()
  2. 4.x 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 $timeout: The new query timeout value to set.

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

Return value

int The previous query timeout value.

Overrides SolrConnectorInterface::adjustTimeout

Deprecated

use useTim

File

src/SolrConnector/SolrConnectorPluginBase.php, line 941

Class

SolrConnectorPluginBase
Defines a base class for Solr connector plugins.

Namespace

Drupal\search_api_solr\SolrConnector

Code

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