/** * Inits the client connections */ protected function _initConnections() { $connections = array(); foreach ($this->getConfig('connections') as $connection) { $connections[] = Connection::create($this->_prepareConnectionParams($connection)); } if (isset($this->_config['servers'])) { foreach ($this->getConfig('servers') as $server) { $connections[] = Connection::create($this->_prepareConnectionParams($server)); } } // If no connections set, create default connection if (empty($connections)) { $connections[] = Connection::create($this->_prepareConnectionParams($this->getConfig())); } if (!isset($this->_config['connectionStrategy'])) { if ($this->getConfig('roundRobin') === true) { $this->setConfigValue('connectionStrategy', 'RoundRobin'); } else { $this->setConfigValue('connectionStrategy', 'Simple'); } } $strategy = Connection\Strategy\StrategyFactory::create($this->getConfig('connectionStrategy')); $this->_connectionPool = new Connection\ConnectionPool($connections, $strategy, $this->_callback); }
/** * Inits the client connections */ protected function _initConnections() { $connections = $this->getConfig('connections'); foreach ($connections as $connection) { $this->_connections[] = Connection::create($connection); } if (isset($_config['servers'])) { $this->_connections[] = Connection::create($this->getConfig('servers')); } // If no connections set, create default connection if (empty($this->_connections)) { $this->_connections[] = Connection::create($this->_configureParams()); } }
/** * @group unit * @expectedException \Elastica\Exception\InvalidException * @expectedException \Elastica\Exception\InvalidException */ public function testCreateInvalid() { Connection::create('test'); }