Remove the "safe" pipeline option.

Just let users specify the appropriate pipeline executor.
This commit is contained in:
Daniele Alessandri
2012-04-27 23:36:12 +02:00
parent 41c29bed4e
commit 743ccc39ae
2 changed files with 11 additions and 13 deletions
+7 -6
View File
@@ -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;
}
/**
@@ -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());
}
/**