Merge branch 'pr/732' into 3.0.x
This commit is contained in:
commit
e5d9c3ddbb
|
@ -15,6 +15,7 @@ To generate a changelog summary since the last version, run
|
||||||
* 3.0.8 (Unreleased)
|
* 3.0.8 (Unreleased)
|
||||||
|
|
||||||
* Fixed handling of empty indexes #760
|
* Fixed handling of empty indexes #760
|
||||||
|
* Added support for `connectionStrategy` Elastica configuration #732
|
||||||
|
|
||||||
* 3.0.7 (2015-01-21)
|
* 3.0.7 (2015-01-21)
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,16 @@ class Configuration implements ConfigurationInterface
|
||||||
return $v;
|
return $v;
|
||||||
})
|
})
|
||||||
->end()
|
->end()
|
||||||
|
// Elastica names its properties with camel case, support both
|
||||||
|
->beforeNormalization()
|
||||||
|
->ifTrue(function ($v) { return isset($v['connection_strategy']); })
|
||||||
|
->then(function ($v) {
|
||||||
|
$v['connectionStrategy'] = $v['connection_strategy'];
|
||||||
|
unset($v['connection_strategy']);
|
||||||
|
|
||||||
|
return $v;
|
||||||
|
})
|
||||||
|
->end()
|
||||||
// If there is no connections array key defined, assume a single connection.
|
// If there is no connections array key defined, assume a single connection.
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
->ifTrue(function ($v) { return is_array($v) && !array_key_exists('connections', $v); })
|
->ifTrue(function ($v) { return is_array($v) && !array_key_exists('connections', $v); })
|
||||||
|
@ -124,6 +134,7 @@ class Configuration implements ConfigurationInterface
|
||||||
->end()
|
->end()
|
||||||
->scalarNode('timeout')->end()
|
->scalarNode('timeout')->end()
|
||||||
->scalarNode('headers')->end()
|
->scalarNode('headers')->end()
|
||||||
|
->scalarNode('connectionStrategy')->defaultValue('Simple')->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
|
|
|
@ -11,6 +11,11 @@ fos_elastica:
|
||||||
connections:
|
connections:
|
||||||
- url: http://es1.example.net:9200
|
- url: http://es1.example.net:9200
|
||||||
- url: http://es2.example.net:9200
|
- url: http://es2.example.net:9200
|
||||||
|
connection_strategy: RoundRobin
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Elastica allows for definition of different connection strategies and by default
|
||||||
|
supports `RoundRobin` and `Simple`. You can see definitions for these strategies
|
||||||
|
in the `Elastica\Connection\Strategy` namespace.
|
||||||
|
|
||||||
For more information on Elastica clustering see http://elastica.io/getting-started/installation.html#section-connect-cluster
|
For more information on Elastica clustering see http://elastica.io/getting-started/installation.html#section-connect-cluster
|
||||||
|
|
48
Tests/Functional/ClientTest.php
Normal file
48
Tests/Functional/ClientTest.php
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of the FOSElasticaBundle project.
|
||||||
|
*
|
||||||
|
* (c) Tim Nagel <tim@nagel.com.au>
|
||||||
|
*
|
||||||
|
* This source file is subject to the MIT license that is bundled
|
||||||
|
* with this source code in the file LICENSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace FOS\ElasticaBundle\Tests\Functional;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group functional
|
||||||
|
*/
|
||||||
|
class ClientTest extends WebTestCase
|
||||||
|
{
|
||||||
|
public function testContainerSource()
|
||||||
|
{
|
||||||
|
$client = $this->createClient(array('test_case' => 'Basic'));
|
||||||
|
|
||||||
|
$es = $client->getContainer()->get('fos_elastica.client.default');
|
||||||
|
$this->assertInstanceOf('Elastica\\Connection\\Strategy\\RoundRobin', $es->getConnectionStrategy());
|
||||||
|
|
||||||
|
$es = $client->getContainer()->get('fos_elastica.client.second_server');
|
||||||
|
$this->assertInstanceOf('Elastica\\Connection\\Strategy\\RoundRobin', $es->getConnectionStrategy());
|
||||||
|
|
||||||
|
$es = $client->getContainer()->get('fos_elastica.client.third');
|
||||||
|
$this->assertInstanceOf('Elastica\\Connection\\Strategy\\Simple', $es->getConnectionStrategy());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->deleteTmpDir('Basic');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
parent::tearDown();
|
||||||
|
|
||||||
|
$this->deleteTmpDir('Basic');
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,7 +15,12 @@ fos_elastica:
|
||||||
- url: http://localhost:9200
|
- url: http://localhost:9200
|
||||||
- host: localhost
|
- host: localhost
|
||||||
port: 9200
|
port: 9200
|
||||||
|
connectionStrategy: RoundRobin
|
||||||
second_server:
|
second_server:
|
||||||
|
connections:
|
||||||
|
- url: http://localhost:9200
|
||||||
|
connection_strategy: RoundRobin
|
||||||
|
third:
|
||||||
url: http://localhost:9200
|
url: http://localhost:9200
|
||||||
indexes:
|
indexes:
|
||||||
index:
|
index:
|
||||||
|
|
Loading…
Reference in a new issue