class TimeoutAwarePsr18Adapter in Acquia Search 3.x
Same name and namespace in other branches
- 2.x src/Client/Adapter/TimeoutAwarePsr18Adapter.php \Drupal\acquia_search\Client\Adapter\TimeoutAwarePsr18Adapter
Psr18 Adapter that implements TimeoutAwareInterface.
Hierarchy
- class \Drupal\acquia_search\Client\Adapter\TimeoutAwarePsr18Adapter implements \Solarium\Core\Client\Adapter\AdapterInterface, \Solarium\Core\Client\Adapter\TimeoutAwareInterface
Expanded class hierarchy of TimeoutAwarePsr18Adapter
1 file declares its use of TimeoutAwarePsr18Adapter
- SearchApiSolrAcquiaConnector.php in src/
Plugin/ SolrConnector/ SearchApiSolrAcquiaConnector.php
File
- src/
Client/ Adapter/ TimeoutAwarePsr18Adapter.php, line 18
Namespace
Drupal\acquia_search\Client\AdapterView source
class TimeoutAwarePsr18Adapter implements AdapterInterface, TimeoutAwareInterface {
/**
* Timeout in seconds.
*
* @var int
*/
protected $timeout;
/**
* Solarium Psr18 Adapter.
*
* @var \Solarium\Core\Client\Adapter\Psr18Adapter
*/
protected $psr18Adapter;
/**
* Constructor of TimeoutAwarePsr18Adapter.
*
* @param \Psr\Http\Client\ClientInterface $httpClient
* Guzzle HTTP Client.
*/
public function __construct(ClientInterface $httpClient) {
$this->psr18Adapter = new Psr18Adapter($httpClient, new RequestFactory(), new StreamFactory());
}
/**
* Retrieves adapter timeout.
*
* @return int
* Timeout in seconds.
*/
public function getTimeout() : int {
return $this->timeout;
}
/**
* Sets adapter timeout.
*
* @param int $timeoutInSeconds
* Timeout in seconds.
*/
public function setTimeout(int $timeoutInSeconds) : void {
$this->timeout = $timeoutInSeconds;
}
/**
* Executes request.
*
* @param \Solarium\Core\Client\Request $request
* Solarium Request.
* @param \Solarium\Core\Client\Endpoint $endpoint
* Solarium Endpoint.
*
* @return \Solarium\Core\Client\Response
* Solarium response object.
*/
public function execute(Request $request, Endpoint $endpoint) : Response {
$request
->setOptions([
'timeout' => $this->timeout,
]);
return $this->psr18Adapter
->execute($request, $endpoint);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TimeoutAwarePsr18Adapter:: |
protected | property | Solarium Psr18 Adapter. | |
TimeoutAwarePsr18Adapter:: |
protected | property | Timeout in seconds. | |
TimeoutAwarePsr18Adapter:: |
public | function | Executes request. | |
TimeoutAwarePsr18Adapter:: |
public | function | Retrieves adapter timeout. | |
TimeoutAwarePsr18Adapter:: |
public | function | Sets adapter timeout. | |
TimeoutAwarePsr18Adapter:: |
public | function | Constructor of TimeoutAwarePsr18Adapter. |