Slightly change interface for connection factories.

This commit is contained in:
Daniele Alessandri
2013-11-11 18:16:04 +01:00
parent 3c6389f4dd
commit acd29ec076
5 changed files with 10 additions and 13 deletions
+1 -1
View File
@@ -108,7 +108,7 @@ class Client implements ClientInterface
$replication = isset($options->replication) && $options->replication;
$connection = $options->{$replication ? 'replication' : 'cluster'};
$options->connections->createAggregated($connection, $parameters);
$options->connections->aggregate($connection, $parameters);
return $connection;
}
+1 -3
View File
@@ -128,13 +128,11 @@ class ConnectionFactory implements ConnectionFactoryInterface
/**
* {@inheritdoc}
*/
public function createAggregated(AggregatedConnectionInterface $connection, Array $parameters)
public function aggregate(AggregatedConnectionInterface $connection, Array $parameters)
{
foreach ($parameters as $node) {
$connection->add($node instanceof SingleConnectionInterface ? $node : $this->create($node));
}
return $connection;
}
/**
@@ -43,11 +43,10 @@ interface ConnectionFactoryInterface
public function create($parameters);
/**
* Prepares an aggregation of connection objects.
* Aggregates single connections into an aggregate connection instance.
*
* @param AggregatedConnectionInterface $cluster Instance of an aggregated connection class.
* @param array $parameters List of parameters for each connection object.
* @return AggregatedConnectionInterface
*/
public function createAggregated(AggregatedConnectionInterface $cluster, Array $parameters);
public function aggregate(AggregatedConnectionInterface $cluster, Array $parameters);
}
+2 -2
View File
@@ -173,7 +173,7 @@ class ClientTest extends StandardTestCase
$cluster = new PredisCluster();
$factory = new ConnectionFactory();
$factory->createAggregated($cluster, array('tcp://localhost:7000', 'tcp://localhost:7001'));
$factory->aggregate($cluster, array('tcp://localhost:7000', 'tcp://localhost:7001'));
$client = new Client($cluster);
@@ -189,7 +189,7 @@ class ClientTest extends StandardTestCase
$replication = new MasterSlaveReplication();
$factory = new ConnectionFactory();
$factory->createAggregated($replication, array('tcp://host1?alias=master', 'tcp://host2?alias=slave'));
$factory->aggregate($replication, array('tcp://host1?alias=master', 'tcp://host2?alias=slave'));
$client = new Client($replication);
@@ -304,7 +304,7 @@ class ConnectionFactoryTest extends StandardTestCase
$factory->expects($this->never())
->method('create');
$factory->createAggregated($cluster, array(new $connectionClass(), new $connectionClass()));
$factory->aggregate($cluster, array(new $connectionClass(), new $connectionClass()));
}
/**
@@ -326,7 +326,7 @@ class ConnectionFactoryTest extends StandardTestCase
return new $connectionClass;
}));
$factory->createAggregated($cluster, array(null, 'tcp://127.0.0.1', array('scheme' => 'tcp'), new $connectionClass()));
$factory->aggregate($cluster, array(null, 'tcp://127.0.0.1', array('scheme' => 'tcp'), new $connectionClass()));
}
/**
@@ -340,7 +340,7 @@ class ConnectionFactoryTest extends StandardTestCase
$factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create'));
$factory->expects($this->never())->method('create');
$factory->createAggregated($cluster, array());
$factory->aggregate($cluster, array());
}
/**
@@ -363,7 +363,7 @@ class ConnectionFactoryTest extends StandardTestCase
}));
$nodes = array('tcp://127.0.0.1:7001?password=foo', 'tcp://127.0.0.1:7002?password=bar');
$factory->createAggregated($cluster, $nodes);
$factory->aggregate($cluster, $nodes);
}