blob: 33161a0743f566f918c5877ff0d24a10bca7d63e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<?php
namespace Pheanstalk\Command;
use Pheanstalk\Exception;
use Pheanstalk\Response;
/**
* The 'release' command.
* Releases a reserved job back onto the ready queue.
*
* @author Paul Annesley
* @package Pheanstalk
* @license http://www.opensource.org/licenses/mit-license.php
*/
class ReleaseCommand
extends AbstractCommand
implements \Pheanstalk\ResponseParser
{
private $_job;
private $_priority;
private $_delay;
/**
* @param object $job Job
* @param int $priority From 0 (most urgent) to 0xFFFFFFFF (least urgent)
* @param int $delay Seconds to wait before job becomes ready
*/
public function __construct($job, $priority, $delay)
{
$this->_job = $job;
$this->_priority = $priority;
$this->_delay = $delay;
}
/* (non-phpdoc)
* @see Command::getCommandLine()
*/
public function getCommandLine()
{
return sprintf(
'release %u %u %u',
$this->_job->getId(),
$this->_priority,
$this->_delay
);
}
/* (non-phpdoc)
* @see ResponseParser::parseResponse()
*/
public function parseResponse($responseLine, $responseData)
{
if ($responseLine == Response::RESPONSE_BURIED) {
throw new Exception\ServerException(sprintf(
'Job %u %s: out of memory trying to grow data structure',
$this->_job->getId(),
$responseLine
));
}
if ($responseLine == Response::RESPONSE_NOT_FOUND) {
throw new Exception\ServerException(sprintf(
'Job %u %s: does not exist or is not reserved by client',
$this->_job->getId(),
$responseLine
));
}
return $this->_createResponse($responseLine);
}
}
|