Passing pipelines

This commit is contained in:
Daniel Mason 2018-05-25 20:52:20 +12:00
parent deb9af2781
commit 1b044f2b7d
4 changed files with 12 additions and 36 deletions

View File

@ -100,6 +100,7 @@ class Resque
*
* @param string $queue The name of the queue to add the job to.
* @param array $item Job description as an array to be JSON encoded.
* @return bool
*/
public static function push($queue, $item)
{
@ -120,14 +121,14 @@ class Resque
* return it.
*
* @param string $queue The name of the queue to fetch an item from.
* @return array Decoded item from the queue.
* @return mixed Decoded item from the queue.
*/
public static function pop($queue)
{
$item = self::redis()->lpop('queue:' . $queue);
if (!$item) {
return;
return false;
}
return json_decode($item, true);

View File

@ -121,7 +121,6 @@ class Resque_Redis
} else {
list($host, $port, $dsnDatabase, $user, $password, $options) = self::parseDsn($server);
// $user is not used, only $password
$timeout = isset($options['timeout']) ? intval($options['timeout']) : null;
$this->redisConnection = new Redis();
@ -231,6 +230,7 @@ class Resque_Redis
* @param string $name The name of the method called.
* @param array $args Array of supplied arguments to the method.
* @return mixed Return value from Resident::call() based on the command.
* @throws Resque_RedisException
*/
public function __call($name, $args)
{
@ -239,10 +239,16 @@ class Resque_Redis
foreach ($args[0] AS $i => $v) {
$args[0][$i] = self::$defaultNamespace . $v;
}
} else {
}
else {
$args[0] = self::$defaultNamespace . $args[0];
}
}
try {
return call_user_func_array(array($this->redisConnection, $name), $args);
} catch (Exception $e) {
throw new Resque_RedisException('Error communicating with Redis: ' . $e->getMessage(), 0, $e);
}
}
public static function getPrefix()

View File

@ -27,23 +27,6 @@ class Resque_Tests_JobTest extends Resque_Tests_TestCase
$this->assertTrue((bool)Resque::enqueue('jobs', 'Test_Job'));
}
/**
* @expectedException Resque_RedisException
*/
// public function testRedisErrorThrowsExceptionOnJobCreation()
// {
// $mockCredis = $this->getMockBuilder('Credis_Client')
// ->setMethods(['connect', '__call'])
// ->getMock();
// $mockCredis->expects($this->any())->method('__call')
// ->will($this->throwException(new CredisException('failure')));
//
// Resque::setBackend(function($database) use ($mockCredis) {
// return new Resque_Redis('localhost:6379', $database, $mockCredis);
// });
// Resque::enqueue('jobs', 'This is a test');
// }
public function testQeueuedJobCanBeReserved()
{
Resque::enqueue('jobs', 'Test_Job');
@ -404,20 +387,6 @@ class Resque_Tests_JobTest extends Resque_Tests_TestCase
$instance = $job->getInstance();
$this->assertInstanceOf('Resque_JobInterface', $instance);
}
public function testDoNotUseFactoryToGetInstance()
{
$payload = array(
'class' => 'Some_Job_Class',
'args' => array(array())
);
$job = new Resque_Job('jobs', $payload);
$factory = $this->getMock('Resque_Job_FactoryInterface');
$testJob = $this->getMock('Resque_JobInterface');
$factory->expects(self::never())->method('create')->will(self::returnValue($testJob));
$instance = $job->getInstance();
$this->assertInstanceOf('Resque_JobInterface', $instance);
}
}
class Some_Job_Class implements Resque_JobInterface

View File

@ -290,6 +290,6 @@ class Resque_Tests_WorkerTest extends Resque_Tests_TestCase
$i++;
}
$this->assertEquals(2, $i);
$this->assertEquals(2, $i, "End");
}
}