/** * @param array $hostDetails * @param array $connectionParams Array of connection parameters * @param \Psr\Log\LoggerInterface $log logger object * @param \Psr\Log\LoggerInterface $trace logger object (for curl traces) * * @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException * @return \Elasticsearch\Connections\GuzzleConnection */ public function __construct($hostDetails, $connectionParams, LoggerInterface $log, LoggerInterface $trace) { if (isset($connectionParams['guzzleClient']) !== true) { $log->critical('guzzleClient must be set in connectionParams'); throw new InvalidArgumentException('guzzleClient must be set in connectionParams'); } if (isset($hostDetails['port']) !== true) { $hostDetails['port'] = 9200; } $this->guzzle = $connectionParams['guzzleClient']; if (isset($connectionParams['connectionParams'])) { $this->connectionOpts = $connectionParams['connectionParams']; } return parent::__construct($hostDetails, $connectionParams, $log, $trace); }
/** * Constructor * * @param string $host Host string * @param int $port Host port * @param array $connectionParams Array of connection parameters * @param \Psr\Log\LoggerInterface $log logger object * @param \Psr\Log\LoggerInterface $trace logger object (for curl traces) * * @throws \Elasticsearch\Common\Exceptions\RuntimeException * @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException * @return CurlMultiConnection */ public function __construct($host, $port, $connectionParams, LoggerInterface $log, LoggerInterface $trace) { if (extension_loaded('curl') !== true) { $log->critical('Curl library/extension is required for CurlMultiConnection.'); throw new RuntimeException('Curl library/extension is required for CurlMultiConnection.'); } if (isset($connectionParams['curlMultiHandle']) !== true) { $log->critical('curlMultiHandle must be set in connectionParams'); throw new InvalidArgumentException('curlMultiHandle must be set in connectionParams'); } if (isset($port) !== true) { $port = 9200; } $connectionParams = $this->transformAuth($connectionParams); $this->curlOpts = $this->generateCurlOpts($connectionParams); $this->multiHandle = $connectionParams['curlMultiHandle']; return parent::__construct($host, $port, $connectionParams, $log, $trace); }
/** * @param array $hostDetails * @param array $connectionParams Array of connection parameters * @param \Psr\Log\LoggerInterface $log logger object * @param \Psr\Log\LoggerInterface $trace logger object (for curl traces) * * @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException * @return \Elasticsearch\Connections\GuzzleConnection */ public function __construct($hostDetails, $connectionParams, LoggerInterface $log, LoggerInterface $trace) { if (isset($hostDetails['port']) !== true) { $hostDetails['port'] = 9200; } if (isset($hostDetails['scheme']) !== true) { $hostDetails['scheme'] = 'http'; } $handler = null; if (isset($connectionParams)) { if (isset($connectionParams['ringphp_handler'])) { $handler = $connectionParams['ringphp_handler']; unset($connectionParams['ringphp_handler']); } $this->connectionOpts = $connectionParams; } if ($handler) { $this->guzzle = new \GuzzleHttp\Client(['handler' => $handler, 'defaults' => ['future' => true]]); } else { $this->guzzle = new \GuzzleHttp\Client(['defaults' => ['future' => true]]); } return parent::__construct($hostDetails, $connectionParams, $log, $trace); }