Skip to content

Commit cc2a5fe

Browse files
tchiotludopolyfractal
authored andcommitted
Allow ConnectionFactory to be override (#456)
1 parent e4530a7 commit cc2a5fe

File tree

6 files changed

+24
-15
lines changed

6 files changed

+24
-15
lines changed

src/Elasticsearch/ConnectionPool/AbstractConnectionPool.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
use Elasticsearch\Common\Exceptions\InvalidArgumentException;
66
use Elasticsearch\ConnectionPool\Selectors\SelectorInterface;
77
use Elasticsearch\Connections\Connection;
8-
use Elasticsearch\Connections\ConnectionFactory;
8+
use Elasticsearch\Connections\ConnectionFactoryInterface;
9+
use Elasticsearch\Connections\ConnectionInterface;
910

1011
/**
1112
* Class AbstractConnectionPool
@@ -39,18 +40,21 @@ abstract class AbstractConnectionPool implements ConnectionPoolInterface
3940
*/
4041
protected $selector;
4142

43+
/** @var array */
44+
protected $connectionPoolParams;
45+
4246
/** @var \Elasticsearch\Connections\ConnectionFactory */
4347
protected $connectionFactory;
4448

4549
/**
4650
* Constructor
4751
*
48-
* @param ConnectionInterface[] $connections The Connections to choose from
49-
* @param SelectorInterface $selector A Selector instance to perform the selection logic for the available connections
50-
* @param ConnectionFactory $factory ConnectionFactory instance
51-
* @param array $connectionPoolParams
52+
* @param ConnectionInterface[] $connections The Connections to choose from
53+
* @param SelectorInterface $selector A Selector instance to perform the selection logic for the available connections
54+
* @param ConnectionFactoryInterface $factory ConnectionFactory instance
55+
* @param array $connectionPoolParams
5256
*/
53-
public function __construct($connections, SelectorInterface $selector, ConnectionFactory $factory, $connectionPoolParams)
57+
public function __construct($connections, SelectorInterface $selector, ConnectionFactoryInterface $factory, $connectionPoolParams)
5458
{
5559
$paramList = array('connections', 'selector', 'connectionPoolParams');
5660
foreach ($paramList as $param) {

src/Elasticsearch/ConnectionPool/SimpleConnectionPool.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22

33
namespace Elasticsearch\ConnectionPool;
44

5-
use Elasticsearch\Common\Exceptions\NoNodesAvailableException;
65
use Elasticsearch\ConnectionPool\Selectors\SelectorInterface;
76
use Elasticsearch\Connections\Connection;
8-
use Elasticsearch\Connections\ConnectionFactory;
7+
use Elasticsearch\Connections\ConnectionFactoryInterface;
98

109
class SimpleConnectionPool extends AbstractConnectionPool implements ConnectionPoolInterface
1110
{
1211

1312
/**
1413
* {@inheritdoc}
1514
*/
16-
public function __construct($connections, SelectorInterface $selector, ConnectionFactory $factory, $connectionPoolParams)
15+
public function __construct($connections, SelectorInterface $selector, ConnectionFactoryInterface $factory, $connectionPoolParams)
1716
{
1817
parent::__construct($connections, $selector, $factory, $connectionPoolParams);
1918
}

src/Elasticsearch/ConnectionPool/SniffingConnectionPool.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Elasticsearch\Common\Exceptions\NoNodesAvailableException;
77
use Elasticsearch\ConnectionPool\Selectors\SelectorInterface;
88
use Elasticsearch\Connections\Connection;
9-
use Elasticsearch\Connections\ConnectionFactory;
9+
use Elasticsearch\Connections\ConnectionFactoryInterface;
1010

1111
class SniffingConnectionPool extends AbstractConnectionPool implements ConnectionPoolInterface
1212
{
@@ -16,7 +16,10 @@ class SniffingConnectionPool extends AbstractConnectionPool implements Connectio
1616
/** @var int */
1717
private $nextSniff = -1;
1818

19-
public function __construct($connections, SelectorInterface $selector, ConnectionFactory $factory, $connectionPoolParams)
19+
/**
20+
* {@inheritdoc}
21+
*/
22+
public function __construct($connections, SelectorInterface $selector, ConnectionFactoryInterface $factory, $connectionPoolParams)
2023
{
2124
parent::__construct($connections, $selector, $factory, $connectionPoolParams);
2225

src/Elasticsearch/ConnectionPool/StaticConnectionPool.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Elasticsearch\Common\Exceptions\NoNodesAvailableException;
66
use Elasticsearch\ConnectionPool\Selectors\SelectorInterface;
77
use Elasticsearch\Connections\Connection;
8-
use Elasticsearch\Connections\ConnectionFactory;
8+
use Elasticsearch\Connections\ConnectionFactoryInterface;
99

1010
class StaticConnectionPool extends AbstractConnectionPool implements ConnectionPoolInterface
1111
{
@@ -22,7 +22,7 @@ class StaticConnectionPool extends AbstractConnectionPool implements ConnectionP
2222
/**
2323
* {@inheritdoc}
2424
*/
25-
public function __construct($connections, SelectorInterface $selector, ConnectionFactory $factory, $connectionPoolParams)
25+
public function __construct($connections, SelectorInterface $selector, ConnectionFactoryInterface $factory, $connectionPoolParams)
2626
{
2727
parent::__construct($connections, $selector, $factory, $connectionPoolParams);
2828
$this->scheduleCheck();

src/Elasticsearch/ConnectionPool/StaticNoPingConnectionPool.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Elasticsearch\Common\Exceptions\NoNodesAvailableException;
66
use Elasticsearch\ConnectionPool\Selectors\SelectorInterface;
77
use Elasticsearch\Connections\Connection;
8-
use Elasticsearch\Connections\ConnectionFactory;
8+
use Elasticsearch\Connections\ConnectionFactoryInterface;
99

1010
class StaticNoPingConnectionPool extends AbstractConnectionPool implements ConnectionPoolInterface
1111
{
@@ -22,7 +22,7 @@ class StaticNoPingConnectionPool extends AbstractConnectionPool implements Conne
2222
/**
2323
* {@inheritdoc}
2424
*/
25-
public function __construct($connections, SelectorInterface $selector, ConnectionFactory $factory, $connectionPoolParams)
25+
public function __construct($connections, SelectorInterface $selector, ConnectionFactoryInterface $factory, $connectionPoolParams)
2626
{
2727
parent::__construct($connections, $selector, $factory, $connectionPoolParams);
2828
}

src/Elasticsearch/Connections/ConnectionFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ class ConnectionFactory implements ConnectionFactoryInterface
1919
/** @var array */
2020
private $connectionParams;
2121

22+
/** @var SerializerInterface */
23+
private $serializer;
24+
2225
/** @var LoggerInterface */
2326
private $logger;
2427

0 commit comments

Comments
 (0)