@@ -2,11 +2,9 @@ |
||
2 | 2 | namespace Dtc\QueueBundle\Command; |
3 | 3 | |
4 | 4 | use Dtc\QueueBundle\Documents\Job; |
5 | - |
|
6 | 5 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
7 | 6 | use Symfony\Component\Console\Input\InputArgument; |
8 | 7 | use Symfony\Component\Console\Input\InputInterface; |
9 | -use Symfony\Component\Console\Input\InputOption; |
|
10 | 8 | use Symfony\Component\Console\Output\OutputInterface; |
11 | 9 | |
12 | 10 | class CreateJobCommand |
@@ -2,9 +2,7 @@ |
||
2 | 2 | namespace Dtc\QueueBundle\Command; |
3 | 3 | |
4 | 4 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
5 | -use Symfony\Component\Console\Input\InputArgument; |
|
6 | 5 | use Symfony\Component\Console\Input\InputInterface; |
7 | -use Symfony\Component\Console\Input\InputOption; |
|
8 | 6 | use Symfony\Component\Console\Output\OutputInterface; |
9 | 7 | |
10 | 8 | class PruneCommand |
@@ -2,7 +2,6 @@ |
||
2 | 2 | namespace Dtc\QueueBundle\Command; |
3 | 3 | |
4 | 4 | use Dtc\QueueBundle\Model\Job; |
5 | - |
|
6 | 5 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
7 | 6 | use Symfony\Component\Console\Input\InputArgument; |
8 | 7 | use Symfony\Component\Console\Input\InputInterface; |
@@ -68,7 +68,7 @@ |
||
68 | 68 | set_time_limit($processTimeout); // Set an hour timeout |
69 | 69 | |
70 | 70 | if ($jobId = $input->getOption('job_id')) { |
71 | - return $this->runJobById($jobId); // Run a single job |
|
71 | + return $this->runJobById($jobId); // Run a single job |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | try { |
@@ -3,10 +3,7 @@ |
||
3 | 3 | |
4 | 4 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
5 | 5 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
6 | - |
|
7 | 6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
8 | -use Symfony\Component\HttpFoundation\Response; |
|
9 | -use Symfony\Component\HttpFoundation\Request; |
|
10 | 7 | |
11 | 8 | class QueueController |
12 | 9 | extends Controller |
@@ -11,6 +11,9 @@ |
||
11 | 11 | protected $dm; |
12 | 12 | protected $documentName; |
13 | 13 | |
14 | + /** |
|
15 | + * @param string $documentName |
|
16 | + */ |
|
14 | 17 | public function __construct(DocumentManager $dm, $documentName) |
15 | 18 | { |
16 | 19 | $this->dm = $dm; |
@@ -179,8 +179,7 @@ |
||
179 | 179 | |
180 | 180 | if ($prioritize) { |
181 | 181 | $qb->sort('priority', 'asc'); |
182 | - } |
|
183 | - else { |
|
182 | + } else { |
|
184 | 183 | $qb->sort('when', 'asc'); |
185 | 184 | } |
186 | 185 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
19 | - * @param field_type $jobClass |
|
19 | + * @param string $jobClass |
|
20 | 20 | */ |
21 | 21 | public function setJobClass($jobClass) |
22 | 22 | { |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | - * @return the $jobManager |
|
32 | + * @return JobManagerInterface $jobManager |
|
33 | 33 | */ |
34 | 34 | public function getJobManager() |
35 | 35 | { |
@@ -53,6 +53,9 @@ discard block |
||
53 | 53 | return new $this->jobClass($this, $batch, $priority, $dateTime); |
54 | 54 | } |
55 | 55 | |
56 | + /** |
|
57 | + * @param integer $priority |
|
58 | + */ |
|
56 | 59 | public function later($delay = 0, $priority = null) |
57 | 60 | { |
58 | 61 | $job = $this->at(time() + $delay, false, $priority); |
@@ -60,6 +63,9 @@ discard block |
||
60 | 63 | return $job; |
61 | 64 | } |
62 | 65 | |
66 | + /** |
|
67 | + * @param integer $priority |
|
68 | + */ |
|
63 | 69 | public function batchLater($delay = 0, $priority = null) |
64 | 70 | { |
65 | 71 | $job = $this->at($delay, true, $priority); |
@@ -67,6 +73,10 @@ discard block |
||
67 | 73 | return $job; |
68 | 74 | } |
69 | 75 | |
76 | + /** |
|
77 | + * @param integer $time |
|
78 | + * @param integer $priority |
|
79 | + */ |
|
70 | 80 | public function batchAt($time = null, $priority = null) |
71 | 81 | { |
72 | 82 | return $this->at($time, true, $priority); |
@@ -45,8 +45,7 @@ |
||
45 | 45 | if ($time) { |
46 | 46 | $dateTime = new \DateTime(); |
47 | 47 | $dateTime->setTimestamp($time); |
48 | - } |
|
49 | - else { |
|
48 | + } else { |
|
50 | 49 | $dateTime = null; |
51 | 50 | } |
52 | 51 |
@@ -33,6 +33,9 @@ |
||
33 | 33 | return $job; |
34 | 34 | } |
35 | 35 | |
36 | + /** |
|
37 | + * @param string $workerName |
|
38 | + */ |
|
36 | 39 | public function getJob($workerName = null, $methodName = null, $prioritize = true) |
37 | 40 | { |
38 | 41 | if ($methodName) { |
@@ -3,7 +3,6 @@ |
||
3 | 3 | |
4 | 4 | use Dtc\QueueBundle\Model\Job as BaseJob; |
5 | 5 | use Dtc\QueueBundle\Model\JobManagerInterface; |
6 | - |
|
7 | 6 | use PhpAmqpLib\Connection\AMQPConnection; |
8 | 7 | use PhpAmqpLib\Message\AMQPMessage; |
9 | 8 |
@@ -15,12 +15,12 @@ |
||
15 | 15 | |
16 | 16 | public function __construct(AMQPConnection $connection) { |
17 | 17 | $this->connection = $connection; |
18 | - $this->channel = $connection->channel();; |
|
18 | + $this->channel = $connection->channel(); ; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function save($job) { |
22 | 22 | $queue = $job->getWorkerName(); |
23 | - $exchange = null; // User default exchange |
|
23 | + $exchange = null; // User default exchange |
|
24 | 24 | |
25 | 25 | $this->channel->queue_declare($queue, false, true, false, false); |
26 | 26 | $this->channel->exchange_declare($exchange, 'direct', false, true, false); |
@@ -67,8 +67,7 @@ |
||
67 | 67 | if ($job->getStatus() === BaseJob::STATUS_SUCCESS) { |
68 | 68 | $this->beanstalkd |
69 | 69 | ->delete($job); |
70 | - } |
|
71 | - else { |
|
70 | + } else { |
|
72 | 71 | $this->beanstalkd |
73 | 72 | ->bury($job); |
74 | 73 | } |
@@ -3,10 +3,7 @@ |
||
3 | 3 | |
4 | 4 | use Dtc\QueueBundle\BeanStalkd\JobManager; |
5 | 5 | use Dtc\QueueBundle\Model\Job; |
6 | -use Dtc\QueueBundle\Model\WorkerManager; |
|
7 | - |
|
8 | 6 | use Dtc\QueueBundle\Tests\FibonacciWorker; |
9 | -use Dtc\QueueBundle\Tests\StaticJobManager; |
|
10 | 7 | use Dtc\QueueBundle\Tests\Model\BaseJobManagerTest; |
11 | 8 | |
12 | 9 | /** |
@@ -3,12 +3,8 @@ |
||
3 | 3 | |
4 | 4 | use Dtc\QueueBundle\Tests\Model\BaseJobManagerTest; |
5 | 5 | use Dtc\QueueBundle\Tests\FibonacciWorker; |
6 | -use Dtc\QueueBundle\Tests\StaticJobManager; |
|
7 | - |
|
8 | -use Dtc\QueueBundle\Model\WorkerManager; |
|
9 | 6 | use Dtc\QueueBundle\Documents\JobManager; |
10 | 7 | use Dtc\QueueBundle\Model\Job; |
11 | - |
|
12 | 8 | use Doctrine\MongoDB\Connection; |
13 | 9 | use Doctrine\ODM\MongoDB\Configuration; |
14 | 10 | use Doctrine\ODM\MongoDB\DocumentManager; |
@@ -48,7 +48,7 @@ |
||
48 | 48 | |
49 | 49 | $documentName = 'Dtc\QueueBundle\Documents\Job'; |
50 | 50 | $sm = self::$dm->getSchemaManager(); |
51 | - $timeout = 1000; |
|
51 | + $timeout = 1000; |
|
52 | 52 | |
53 | 53 | $sm->dropDocumentCollection($documentName); |
54 | 54 | $sm->createDocumentCollection($documentName); |