Skip to content

Commit 3923432

Browse files
Oliboy50polyfractal
authored andcommitted
add ClientBuilder->setConnectionParams() (#507)
1 parent 30baa0d commit 3923432

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/Elasticsearch/ClientBuilder.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class ClientBuilder
7171
/** @var array */
7272
private $hosts;
7373

74+
/** @var array */
75+
private $connectionParams;
76+
7477
/** @var int */
7578
private $retries;
7679

@@ -312,6 +315,17 @@ public function setHosts($hosts)
312315
return $this;
313316
}
314317

318+
/**
319+
* @param array $params
320+
* @return $this
321+
*/
322+
public function setConnectionParams(array $params)
323+
{
324+
$this->connectionParams = $params;
325+
326+
return $this;
327+
}
328+
315329
/**
316330
* @param int $retries
317331
* @return $this
@@ -425,8 +439,10 @@ public function build()
425439
}
426440

427441
if (is_null($this->connectionFactory)) {
428-
$connectionParams = [];
429-
$this->connectionFactory = new ConnectionFactory($this->handler, $connectionParams, $this->serializer, $this->logger, $this->tracer);
442+
if (is_null($this->connectionParams)) {
443+
$this->connectionParams = [];
444+
}
445+
$this->connectionFactory = new ConnectionFactory($this->handler, $this->connectionParams, $this->serializer, $this->logger, $this->tracer);
430446
}
431447

432448
if (is_null($this->hosts)) {

0 commit comments

Comments
 (0)