Skip to content

Commit d1650c6

Browse files
committed
Switched Codeformatter to ZendStudio 7.2.x
No Content Changes.
1 parent 2049ec6 commit d1650c6

File tree

6 files changed

+45
-48
lines changed

6 files changed

+45
-48
lines changed

config/sql/queue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function before($event = array()) {
1616

1717
function after($event = array()) {
1818
}
19-
19+
2020
public $queued_tasks = array(
2121
'id' => array(
2222
'type' => 'integer',

models/queued_task.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
* @link http://github.com/MSeven/cakephp_queue
99
*/
1010
class QueuedTask extends AppModel {
11-
11+
1212
public $name = 'QueuedTask';
13-
13+
1414
public $rateHistory = array();
15-
15+
1616
public $exit = false;
1717

1818
/**
@@ -23,7 +23,7 @@ class QueuedTask extends AppModel {
2323
* @return bool success
2424
*/
2525
public function createJob($jobName, $data, $notBefore = null) {
26-
26+
2727
$data = array(
2828
'jobtype' => $jobName,
2929
'data' => serialize($data)
@@ -47,7 +47,7 @@ public function onError() {
4747
public function requestJob($capabilities) {
4848
$idlist = array();
4949
$wasFetched = array();
50-
50+
5151
$findConf = array(
5252
'conditions' => array(
5353
'completed' => null,
@@ -219,7 +219,7 @@ public function cleanOldJobs() {
219219
$this->deleteAll(array(
220220
'completed < ' => date('Y-m-d H:i:s', time() - Configure::read('queue.cleanuptimeout'))
221221
));
222-
222+
223223
}
224224

225225
}

tests/cases/models/queued_task.test.php

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ public function testQueueInstance() {
5454
public function testCreateAndCount() {
5555
// at first, the queue should contain 0 items.
5656
$this->assertEqual(0, $this->QueuedTask->getLength());
57-
57+
5858
// create a job
5959
$this->assertTrue($this->QueuedTask->createJob('test1', array(
6060
'some' => 'random',
6161
'test' => 'data'
6262
)));
63-
63+
6464
// test if queue Length is 1 now.
6565
$this->assertEqual(1, $this->QueuedTask->getLength());
66-
66+
6767
//create some more jobs
6868
$this->assertTrue($this->QueuedTask->createJob('test2', array(
6969
'some' => 'random',
@@ -77,10 +77,10 @@ public function testCreateAndCount() {
7777
'some' => 'random',
7878
'test' => 'data4'
7979
)));
80-
80+
8181
//overall queueLength shpould now be 4
8282
$this->assertEqual(4, $this->QueuedTask->getLength());
83-
83+
8484
// there should be 1 task of type 'test1', one of type 'test3' and 2 of type 'test2'
8585
$this->assertEqual(1, $this->QueuedTask->getLength('test1'));
8686
$this->assertEqual(2, $this->QueuedTask->getLength('test2'));
@@ -103,7 +103,7 @@ public function testCreateAndFetch() {
103103
'x4' => 'y4'
104104
);
105105
// start off empty.
106-
106+
107107

108108
$this->assertEqual(array(), $this->QueuedTask->find('all'));
109109
// at first, the queue should contain 0 items.
@@ -112,21 +112,21 @@ public function testCreateAndFetch() {
112112
$this->assertFalse($this->QueuedTask->requestJob($capabilities));
113113
// insert one job.
114114
$this->assertTrue($this->QueuedTask->createJob('task1', $testData));
115-
115+
116116
// fetch and check the first job.
117117
$data = $this->QueuedTask->requestJob($capabilities);
118118
$this->assertEqual(1, $data['id']);
119119
$this->assertEqual('task1', $data['jobtype']);
120120
$this->assertEqual(0, $data['failed']);
121121
$this->assertNull($data['completed']);
122122
$this->assertEqual($testData, unserialize($data['data']));
123-
123+
124124
// after this job has been fetched, it may not be reassigned.
125125
$this->assertEqual(array(), $this->QueuedTask->requestJob($capabilities));
126-
126+
127127
// queue length is still 1 since the first job did not finish.
128128
$this->assertEqual(1, $this->QueuedTask->getLength());
129-
129+
130130
// Now mark Task1 as done
131131
$this->assertTrue($this->QueuedTask->markJobDone(1));
132132
// Should be 0 again.
@@ -156,7 +156,7 @@ public function testSequence() {
156156
}
157157
// 10 jobs in the queue.
158158
$this->assertEqual(10, $this->QueuedTask->getLength());
159-
159+
160160
// jobs should be fetched in the original sequence.
161161
foreach (range(0, 4) as $num) {
162162
$job = $this->QueuedTask->requestJob($capabilities);
@@ -168,7 +168,7 @@ public function testSequence() {
168168
$this->assertTrue($this->QueuedTask->markJobDone($num + 1));
169169
$this->assertEqual(9 - $num, $this->QueuedTask->getLength());
170170
}
171-
171+
172172
// jobs should be fetched in the original sequence.
173173
foreach (range(5, 9) as $num) {
174174
$job = $this->QueuedTask->requestJob($capabilities);
@@ -217,7 +217,7 @@ public function testNotBeforeOrder() {
217217
$this->assertTrue($this->QueuedTask->createJob('task1', 'three', '- 3 Seconds'));
218218
$this->assertTrue($this->QueuedTask->createJob('task1', 'two', '- 4 Seconds'));
219219
$this->assertTrue($this->QueuedTask->createJob('task1', 'one', '- 5 Seconds'));
220-
220+
221221
// when usin requestJob, the jobs we just created should be delivered in this order, NOT the order in which they where created.
222222
$expected = array(
223223
array(
@@ -241,7 +241,7 @@ public function testNotBeforeOrder() {
241241
'data' => ''
242242
)
243243
);
244-
244+
245245
foreach ($expected as $item) {
246246
$tmp = $this->QueuedTask->requestJob($capabilities);
247247
$this->assertEqual($item['name'], $tmp['jobtype']);
@@ -267,59 +267,59 @@ public function testRateLimit() {
267267
'retries' => 2
268268
)
269269
);
270-
270+
271271
// clear out the rate history
272272
$this->QueuedTask->rateHistory = array();
273-
273+
274274
$this->assertTrue($this->QueuedTask->createJob('task1', '1'));
275275
$this->assertTrue($this->QueuedTask->createJob('task1', '2'));
276276
$this->assertTrue($this->QueuedTask->createJob('task1', '3'));
277277
$this->assertTrue($this->QueuedTask->createJob('dummytask', null));
278278
$this->assertTrue($this->QueuedTask->createJob('dummytask', null));
279279
$this->assertTrue($this->QueuedTask->createJob('dummytask', null));
280280
$this->assertTrue($this->QueuedTask->createJob('dummytask', null));
281-
281+
282282
//At first we get task1-1.
283283
$tmp = $this->QueuedTask->requestJob($capabilities);
284284
$this->assertEqual($tmp['jobtype'], 'task1');
285285
$this->assertEqual(unserialize($tmp['data']), '1');
286-
286+
287287
//The rate limit should now skip over task1-2 and fetch a dummytask.
288288
$tmp = $this->QueuedTask->requestJob($capabilities);
289289
$this->assertEqual($tmp['jobtype'], 'dummytask');
290290
$this->assertEqual(unserialize($tmp['data']), null);
291-
291+
292292
//and again.
293293
$tmp = $this->QueuedTask->requestJob($capabilities);
294294
$this->assertEqual($tmp['jobtype'], 'dummytask');
295295
$this->assertEqual(unserialize($tmp['data']), null);
296-
296+
297297
//Then some time passes
298298
sleep(1);
299-
299+
300300
//Now we should get task1-2
301301
$tmp = $this->QueuedTask->requestJob($capabilities);
302302
$this->assertEqual($tmp['jobtype'], 'task1');
303303
$this->assertEqual(unserialize($tmp['data']), '2');
304-
304+
305305
//and again rate limit to dummytask.
306306
$tmp = $this->QueuedTask->requestJob($capabilities);
307307
$this->assertEqual($tmp['jobtype'], 'dummytask');
308308
$this->assertEqual(unserialize($tmp['data']), null);
309-
309+
310310
//Then some more time passes
311311
sleep(1);
312-
312+
313313
//Now we should get task1-3
314314
$tmp = $this->QueuedTask->requestJob($capabilities);
315315
$this->assertEqual($tmp['jobtype'], 'task1');
316316
$this->assertEqual(unserialize($tmp['data']), '3');
317-
317+
318318
//and again rate limit to dummytask.
319319
$tmp = $this->QueuedTask->requestJob($capabilities);
320320
$this->assertEqual($tmp['jobtype'], 'dummytask');
321321
$this->assertEqual(unserialize($tmp['data']), null);
322-
322+
323323
//and now the queue is empty
324324
$tmp = $this->QueuedTask->requestJob($capabilities);
325325
$this->assertEqual($tmp, null);
@@ -334,7 +334,7 @@ public function testRequeueAfterTimeout() {
334334
'rate' => 0
335335
)
336336
);
337-
337+
338338
$this->assertTrue($this->QueuedTask->createJob('task1', '1'));
339339
$tmp = $this->QueuedTask->requestJob($capabilities);
340340
$this->assertEqual($tmp['jobtype'], 'task1');

vendors/shells/queue.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class queueShell extends Shell {
1717
* @var QueuedTask
1818
*/
1919
public $QueuedTask;
20-
20+
2121
private $taskConf;
2222

2323
/**
@@ -26,7 +26,7 @@ class queueShell extends Shell {
2626
public function initialize() {
2727
App::import('Folder');
2828
$this->_loadModels();
29-
29+
3030
foreach ($this->Dispatch->shellPaths as $path) {
3131
$folder = new Folder($path . DS . 'tasks');
3232
$this->tasks = array_merge($this->tasks, $folder->find('queue_.*\.php'));
@@ -35,10 +35,10 @@ public function initialize() {
3535
foreach ($this->tasks as &$task) {
3636
$task = basename($task, '.php');
3737
}
38-
38+
3939
//Config can be overwritten via local app config.
4040
Configure::load('queue');
41-
41+
4242
$conf = Configure::read('queue');
4343
if (!is_array($conf)) {
4444
$conf = array();
@@ -93,7 +93,7 @@ public function add() {
9393
$this->out('Please call like this:');
9494
$this->out(' cake queue add <taskname>');
9595
} else {
96-
96+
9797
if (in_array($this->args[0], $this->taskNames)) {
9898
$this->{$this->args[0]}->add();
9999
} elseif (in_array('queue_' . $this->args[0], $this->taskNames)) {
@@ -116,7 +116,7 @@ public function add() {
116116
public function runworker() {
117117
$exit = false;
118118
$starttime = time();
119-
119+
120120
while (!$exit) {
121121
$this->out('Looking for Job....');
122122
$data = $this->QueuedTask->requestJob($this->getTaskConf());
@@ -138,7 +138,7 @@ public function runworker() {
138138
$this->out('nothing to do, sleeping.');
139139
sleep(Configure::read('queue.sleeptime'));
140140
}
141-
141+
142142
// check if we are over the maximum runtime and end processing if so.
143143
if (Configure::read('queue.workermaxruntime') != 0 && (time() - $starttime) >= Configure::read('queue.workermaxruntime')) {
144144
$exit = true;
@@ -168,9 +168,9 @@ public function clean() {
168168
*/
169169
public function stats() {
170170
$this->out('Jobs currenty in the Queue:');
171-
171+
172172
$types = $this->QueuedTask->getTypes();
173-
173+
174174
foreach ($types as $type) {
175175
$this->out(" " . str_pad($type, 20, ' ', STR_PAD_RIGHT) . ": " . $this->QueuedTask->getLength($type));
176176
}

vendors/shells/tasks/queue_email.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
/**
43
54
* @package QueuePlugin
@@ -28,7 +27,6 @@ class queueEmailTask extends Shell {
2827
'additionalParams' => '',
2928
'layout' => 'default'
3029
);
31-
3230
public $timeout = 120;
3331
public $retries = 0;
3432
/**
@@ -37,7 +35,6 @@ class queueEmailTask extends Shell {
3735
* @var Controller
3836
*/
3937
public $Controller;
40-
4138
/**
4239
* EmailComponent
4340
*

vendors/shells/tasks/queue_example.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ class queueExampleTask extends Shell {
2121
public $uses = array(
2222
'Queue.QueuedTask'
2323
);
24-
24+
2525
/**
2626
* ZendStudio Codecomplete Hint
2727
*
2828
* @var QueuedTask
2929
*/
3030
public $QueuedTask;
31-
31+
3232
/**
3333
* Timeout für run, after which the Task is reassigned to a new worker.
3434
*

0 commit comments

Comments
 (0)