@@ -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; |
@@ -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) { |
@@ -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); |
@@ -104,6 +104,11 @@ |
||
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | + /** |
|
108 | + * @param integer|null $time |
|
109 | + * @param string $method |
|
110 | + * @param integer $priority |
|
111 | + */ |
|
107 | 112 | protected function assertJob(Job $job, $time, $method, $priority = null) { |
108 | 113 | $this->assertNotEmpty($job->getId(), "Job should have an id"); |
109 | 114 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | public function hasListeners($eventName) |
17 | 17 | { |
18 | - if ( ! isset($this->listeners[$eventName])) { |
|
18 | + if (!isset($this->listeners[$eventName])) { |
|
19 | 19 | return false; |
20 | 20 | } |
21 | 21 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | public function dispatch($eventName, Event $event) |
26 | 26 | { |
27 | - if ( ! isset($this->listeners[$eventName])) { |
|
27 | + if (!isset($this->listeners[$eventName])) { |
|
28 | 28 | return; |
29 | 29 | } |
30 | 30 |
@@ -20,7 +20,7 @@ |
||
20 | 20 | |
21 | 21 | public function fibonacci($n) |
22 | 22 | { |
23 | - if($n == 0) |
|
23 | + if ($n == 0) |
|
24 | 24 | return 0; //F0 |
25 | 25 | elseif ($n == 1) |
26 | 26 | return 1; //F1 |
@@ -83,7 +83,7 @@ |
||
83 | 83 | public function testPerformance() { |
84 | 84 | $start = microtime(true); |
85 | 85 | $jobsTotal = 1000; |
86 | - self::$jobManager->enableSorting = false; // Ignore priority |
|
86 | + self::$jobManager->enableSorting = false; // Ignore priority |
|
87 | 87 | |
88 | 88 | for ($i = 0; $i < $jobsTotal; $i++) { |
89 | 89 | self::$worker->later()->fibonacci(1); |
@@ -13,7 +13,7 @@ |
||
13 | 13 | $worker = new FibonacciWorker(); |
14 | 14 | $job = new Job($worker, false, null); |
15 | 15 | $job->setArgs(array(1)); |
16 | - $job->setArgs(array(1, array(1,2))); |
|
16 | + $job->setArgs(array(1, array(1, 2))); |
|
17 | 17 | |
18 | 18 | try { |
19 | 19 | $job->setArgs(array($job)); |
@@ -65,7 +65,7 @@ |
||
65 | 65 | public function save($job) { |
66 | 66 | if (!$job->getId()) { |
67 | 67 | $job->setId($this->uniqeId); |
68 | - $this->jobs[$job->getWorkerName()][$this->uniqeId] = $job; |
|
68 | + $this->jobs[$job->getWorkerName()][$this->uniqeId] = $job; |
|
69 | 69 | if ($this->enableSorting) { |
70 | 70 | uasort($this->jobs[$job->getWorkerName()], array($this, 'compareJobPriority')); |
71 | 71 | } |
@@ -41,14 +41,14 @@ |
||
41 | 41 | $config->setHydratorDir('/tmp/dtcqueuetest/generate/hydrators'); |
42 | 42 | $config->setHydratorNamespace('Hydrators'); |
43 | 43 | |
44 | - $classPath = __DIR__ . '../../Documents'; |
|
44 | + $classPath = __DIR__.'../../Documents'; |
|
45 | 45 | $config->setMetadataDriverImpl(AnnotationDriver::create($classPath)); |
46 | 46 | |
47 | 47 | self::$dm = DocumentManager::create(new Connection(), $config); |
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); |