1 | <?php |
||
10 | class JobManager extends AbstractJobManager |
||
11 | { |
||
12 | const DEFAULT_RESERVE_TIMEOUT = 5; // seconds |
||
13 | |||
14 | /** @var Pheanstalk */ |
||
15 | protected $beanstalkd; |
||
16 | |||
17 | protected $tube; |
||
18 | |||
19 | protected $reserveTimeout = self::DEFAULT_RESERVE_TIMEOUT; |
||
20 | |||
21 | 1 | public function setBeanstalkd(Pheanstalk $beanstalkd) |
|
25 | |||
26 | public function setTube($tube) |
||
30 | |||
31 | public function setReserveTimeout($timeout) |
||
35 | |||
36 | 4 | public function save(\Dtc\QueueBundle\Model\Job $job) |
|
54 | |||
55 | 4 | public function getBeanJob($jobId, $data) |
|
59 | |||
60 | /** |
||
61 | * @param string|null $workerName |
||
62 | * @param string|null $methodName |
||
63 | * @param bool $prioritize |
||
64 | * @param int|string|null $runId |
||
65 | * |
||
66 | * @return Job|null |
||
67 | * |
||
68 | * @throws UnsupportedException |
||
69 | */ |
||
70 | 5 | public function getJob($workerName = null, $methodName = null, $prioritize = true, $runId = null) |
|
91 | |||
92 | /** |
||
93 | * @param Pheanstalk $beanstalkd |
||
94 | * @param bool $expiredJob |
||
95 | * @param int|string|null $runId |
||
96 | * |
||
97 | * @return Job|null |
||
98 | */ |
||
99 | 4 | protected function findJob(Pheanstalk $beanstalkd, &$expiredJob, $runId) |
|
121 | |||
122 | 2 | public function deleteJob(\Dtc\QueueBundle\Model\Job $job) |
|
127 | |||
128 | // Save History get called upon completion of the job |
||
129 | public function saveHistory(\Dtc\QueueBundle\Model\Job $job) |
||
130 | { |
||
131 | if (BaseJob::STATUS_SUCCESS === $job->getStatus()) { |
||
132 | $this->beanstalkd |
||
133 | ->delete($job); |
||
134 | } |
||
135 | } |
||
136 | |||
137 | 1 | public function getStats() |
|
141 | } |
||
142 |