Ver Fonte

Swap params order in redis-sentinel constructor.

Daniele Alessandri há 8 anos atrás
pai
commit
c1de65c4ee

+ 1 - 1
src/Configuration/ReplicationOption.php

@@ -42,7 +42,7 @@ class ReplicationOption implements OptionInterface
 
         if ($value === 'sentinel') {
             return function ($sentinels, $options) {
-                return new SentinelReplication($sentinels, $options->service, $options->connections);
+                return new SentinelReplication($options->service, $sentinels, $options->connections);
             };
         }
 

+ 2 - 2
src/Connection/Aggregate/SentinelReplication.php

@@ -101,14 +101,14 @@ class SentinelReplication implements ReplicationInterface
     protected $updateSentinels = false;
 
     /**
-     * @param array                      $sentinels         Sentinel servers connection parameters.
      * @param string                     $service           Name of the service for autodiscovery.
+     * @param array                      $sentinels         Sentinel servers connection parameters.
      * @param ConnectionFactoryInterface $connectionFactory Connection factory instance.
      * @param ReplicationStrategy        $strategy          Replication strategy instance.
      */
     public function __construct(
-        array $sentinels,
         $service,
+        array $sentinels,
         ConnectionFactoryInterface $connectionFactory,
         ReplicationStrategy $strategy = null
     ) {

+ 3 - 3
tests/Predis/Connection/Aggregate/SentinelReplicationTest.php

@@ -1040,7 +1040,7 @@ class SentinelReplicationTest extends PredisTestCase
         $factory = new Connection\Factory();
 
         $replication = new SentinelReplication(
-            array('tcp://127.0.0.1:5381?alias=sentinel1'), 'svc', $factory, $strategy
+            'svc', array('tcp://127.0.0.1:5381?alias=sentinel1'), $factory, $strategy
         );
 
         $this->assertSame($strategy, $replication->getReplicationStrategy());
@@ -1060,7 +1060,7 @@ class SentinelReplicationTest extends PredisTestCase
         $strategy = new Replication\ReplicationStrategy();
         $factory = new Connection\Factory();
 
-        $replication = new SentinelReplication(array($sentinel1), 'svc', $factory, $strategy);
+        $replication = new SentinelReplication('svc', array($sentinel1), $factory, $strategy);
 
         $replication->add($master);
         $replication->add($slave1);
@@ -1091,7 +1091,7 @@ class SentinelReplicationTest extends PredisTestCase
     {
         $factory = $factory ?: new Connection\Factory();
 
-        $replication = new SentinelReplication($sentinels, $service, $factory);
+        $replication = new SentinelReplication($service, $sentinels, $factory);
         $replication->setRetryWait(0);
 
         return $replication;