Jelajahi Sumber

Remove the "safe" pipeline option.

Just let users specify the appropriate pipeline executor.
Daniele Alessandri 13 tahun lalu
induk
melakukan
743ccc39ae

+ 7 - 6
lib/Predis/Pipeline/PipelineContext.php

@@ -68,16 +68,17 @@ class PipelineContext implements BasicClientInterface, ExecutableContextInterfac
             return $executor;
         }
 
-        if (isset($options['safe']) && $options['safe'] == true) {
-            $isCluster = Helpers::isCluster($client->getConnection());
-            return $isCluster ? new SafeClusterExecutor() : new SafeExecutor();
-        }
+        $clientOpts = $client->getOptions();
+        $useExceptions = isset($clientOpts->exceptions) ? $clientOpts->exceptions : true;
 
+        return new StandardExecutor($useExceptions);
+    }
+
+    protected function getDefaultExecutor()
+    {
         $clientOpts = $client->getOptions();
         $useExceptions = isset($clientOpts->exceptions) ? $clientOpts->exceptions : true;
         $executor = new StandardExecutor($useExceptions);
-
-        return $executor;
     }
 
     /**

+ 4 - 7
tests/Predis/Pipeline/PipelineContextTest.php

@@ -41,16 +41,13 @@ class PipelineContextTest extends StandardTestCase
     {
         $client = new Client();
         $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface');
+
         $pipeline = new PipelineContext($client, array('executor' => $executor));
         $this->assertSame($executor, $pipeline->getExecutor());
 
-        $pipeline = new PipelineContext($client, array('safe' => true));
-        $this->assertInstanceOf('Predis\Pipeline\SafeExecutor', $pipeline->getExecutor());
-
-        $options = array('executor' => 'safe');
-        $client = new Client($this->getMock('Predis\Connection\ClusterConnectionInterface'));
-        $pipeline = new PipelineContext($client, array('safe' => true));
-        $this->assertInstanceOf('Predis\Pipeline\SafeClusterExecutor', $pipeline->getExecutor());
+        $executorCbk = function($client, $options) use($executor) { return $executor; };
+        $pipeline = new PipelineContext($client, array('executor' => $executorCbk));
+        $this->assertSame($executor, $pipeline->getExecutor());
     }
 
     /**