You are here

class TimeoutAwarePsr18Adapter in Acquia Search 3.x

Same name and namespace in other branches
  1. 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\Adapter
View 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

Namesort descending Modifiers Type Description Overrides
TimeoutAwarePsr18Adapter::$psr18Adapter protected property Solarium Psr18 Adapter.
TimeoutAwarePsr18Adapter::$timeout protected property Timeout in seconds.
TimeoutAwarePsr18Adapter::execute public function Executes request.
TimeoutAwarePsr18Adapter::getTimeout public function Retrieves adapter timeout.
TimeoutAwarePsr18Adapter::setTimeout public function Sets adapter timeout.
TimeoutAwarePsr18Adapter::__construct public function Constructor of TimeoutAwarePsr18Adapter.