@@ -27,6 +27,9 @@ discard block |
||
| 27 | 27 | protected $hostname; |
| 28 | 28 | protected $pid; |
| 29 | 29 | |
| 30 | + /** |
|
| 31 | + * @param string $cacheKeyPrefix |
|
| 32 | + */ |
|
| 30 | 33 | public function __construct(RunManager $runManager, JobTimingManager $jobTimingManager, $jobClass, $cacheKeyPrefix) |
| 31 | 34 | { |
| 32 | 35 | $this->cacheKeyPrefix = $cacheKeyPrefix; |
@@ -46,6 +49,9 @@ discard block |
||
| 46 | 49 | return $this->cacheKeyPrefix.'_job_'.$jobId; |
| 47 | 50 | } |
| 48 | 51 | |
| 52 | + /** |
|
| 53 | + * @param string $jobCrc |
|
| 54 | + */ |
|
| 49 | 55 | protected function getJobCrcHashKey($jobCrc) |
| 50 | 56 | { |
| 51 | 57 | return $this->cacheKeyPrefix.'_job_crc_'.$jobCrc; |
@@ -103,6 +109,9 @@ discard block |
||
| 103 | 109 | return null; |
| 104 | 110 | } |
| 105 | 111 | |
| 112 | + /** |
|
| 113 | + * @param string $foundJobCacheKey |
|
| 114 | + */ |
|
| 106 | 115 | protected function batchFoundJob(\Dtc\QueueBundle\Redis\Job $job, $foundJobCacheKey, $foundJobMessage) |
| 107 | 116 | { |
| 108 | 117 | $when = $job->getWhenUs(); |
@@ -174,7 +183,7 @@ discard block |
||
| 174 | 183 | /** |
| 175 | 184 | * @param \Dtc\QueueBundle\Model\Job $job |
| 176 | 185 | * |
| 177 | - * @return \Dtc\QueueBundle\Model\Job |
|
| 186 | + * @return null|Job |
|
| 178 | 187 | * |
| 179 | 188 | * @throws ClassNotSubclassException |
| 180 | 189 | */ |
@@ -288,6 +297,9 @@ discard block |
||
| 288 | 297 | } |
| 289 | 298 | } |
| 290 | 299 | |
| 300 | + /** |
|
| 301 | + * @param string $workerName |
|
| 302 | + */ |
|
| 291 | 303 | protected function verifyGetJobArgs($workerName = null, $methodName = null, $prioritize = true) |
| 292 | 304 | { |
| 293 | 305 | if (null !== $workerName || null !== $methodName || (null !== $this->maxPriority && true !== $prioritize)) { |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | ]; |
| 71 | 71 | |
| 72 | 72 | try { |
| 73 | - $this->predis->transaction($options, function ($tx) use ($key, &$element) { |
|
| 73 | + $this->predis->transaction($options, function($tx) use ($key, &$element) { |
|
| 74 | 74 | @list($element) = $tx->zrange($key, 0, 0); |
| 75 | 75 | |
| 76 | 76 | if (isset($element)) { |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | ]; |
| 96 | 96 | |
| 97 | 97 | try { |
| 98 | - $this->predis->transaction($options, function ($tx) use ($key, $max, &$element) { |
|
| 98 | + $this->predis->transaction($options, function($tx) use ($key, $max, &$element) { |
|
| 99 | 99 | @list($element) = $tx->zrangebyscore($key, 0, $max, ['LIMIT' => [0, 1]]); |
| 100 | 100 | |
| 101 | 101 | if (isset($element)) { |
@@ -522,13 +522,13 @@ |
||
| 522 | 522 | |
| 523 | 523 | return $node; |
| 524 | 524 | })->end() |
| 525 | - ->validate()->ifTrue(function ($node) { |
|
| 526 | - if (isset($node['ssl_options']) && !$node['ssl']) { |
|
| 527 | - return true; |
|
| 528 | - } |
|
| 525 | + ->validate()->ifTrue(function ($node) { |
|
| 526 | + if (isset($node['ssl_options']) && !$node['ssl']) { |
|
| 527 | + return true; |
|
| 528 | + } |
|
| 529 | 529 | |
| 530 | - return false; |
|
| 531 | - })->thenInvalid('ssl must be true in order to set ssl_options')->end() |
|
| 530 | + return false; |
|
| 531 | + })->thenInvalid('ssl must be true in order to set ssl_options')->end() |
|
| 532 | 532 | ->end(); |
| 533 | 533 | |
| 534 | 534 | return $rootNode; |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | ->scalarNode('alias') |
| 302 | 302 | ->defaultNull()->end() |
| 303 | 303 | ->end() |
| 304 | - ->validate()->ifTrue(function ($node) { |
|
| 304 | + ->validate()->ifTrue(function($node) { |
|
| 305 | 305 | if (isset($node['type']) && !isset($node['alias'])) { |
| 306 | 306 | return false; |
| 307 | 307 | } |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | ->scalarNode('dsn')->defaultNull()->end() |
| 318 | 318 | ->append($this->addPredisArgs()) |
| 319 | 319 | ->end() |
| 320 | - ->validate()->ifTrue(function ($node) { |
|
| 320 | + ->validate()->ifTrue(function($node) { |
|
| 321 | 321 | if (isset($node['dsn']) && (isset($node['connection_parameters']['host']) || isset($node['connection_parameters']['port']))) { |
| 322 | 322 | return false; |
| 323 | 323 | } |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | ->end() |
| 328 | 328 | ->append($this->addPhpRedisArgs()) |
| 329 | 329 | ->end() |
| 330 | - ->validate()->ifTrue(function ($node) { |
|
| 330 | + ->validate()->ifTrue(function($node) { |
|
| 331 | 331 | if ((isset($node['predis']['dsn']) || isset($node['predis']['connection_parameters']['host'])) && |
| 332 | 332 | (isset($node['snc_redis']['type']) || isset($node['phpredis']['host']))) { |
| 333 | 333 | return false; |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | ->floatNode('read_timeout')->defaultValue(0)->end() |
| 363 | 363 | ->scalarNode('auth')->end() |
| 364 | 364 | ->end() |
| 365 | - ->validate()->ifTrue(function ($node) { |
|
| 365 | + ->validate()->ifTrue(function($node) { |
|
| 366 | 366 | if (!empty($node) && !isset($node['host'])) { |
| 367 | 367 | return false; |
| 368 | 368 | } |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | ->booleanNode('iterable_multibulk')->defaultFalse()->end() |
| 396 | 396 | ->booleanNode('throw_errors')->defaultTrue()->end() |
| 397 | 397 | ->end() |
| 398 | - ->validate()->ifTrue(function ($node) { |
|
| 398 | + ->validate()->ifTrue(function($node) { |
|
| 399 | 399 | if (isset($node['host']) && !isset($node['port'])) { |
| 400 | 400 | return false; |
| 401 | 401 | } |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | $rootNode |
| 436 | 436 | ->prototype('variable')->end() |
| 437 | 437 | ->validate() |
| 438 | - ->ifTrue(function ($node) { |
|
| 438 | + ->ifTrue(function($node) { |
|
| 439 | 439 | if (!is_array($node)) { |
| 440 | 440 | return true; |
| 441 | 441 | } |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | ->append($this->addRabbitMqArgs()) |
| 513 | 513 | ->append($this->addRabbitMqExchange()) |
| 514 | 514 | ->end() |
| 515 | - ->validate()->always(function ($node) { |
|
| 515 | + ->validate()->always(function($node) { |
|
| 516 | 516 | if (empty($node['ssl_options'])) { |
| 517 | 517 | unset($node['ssl_options']); |
| 518 | 518 | } |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | |
| 523 | 523 | return $node; |
| 524 | 524 | })->end() |
| 525 | - ->validate()->ifTrue(function ($node) { |
|
| 525 | + ->validate()->ifTrue(function($node) { |
|
| 526 | 526 | if (isset($node['ssl_options']) && !$node['ssl']) { |
| 527 | 527 | return true; |
| 528 | 528 | } |
@@ -286,7 +286,7 @@ |
||
| 286 | 286 | self::assertEquals(1, $count); |
| 287 | 287 | $allCount = $this->runCountQuery($jobManager->getJobClass()); |
| 288 | 288 | $counter = 0; |
| 289 | - $countJobs = function ($count) use (&$counter) { |
|
| 289 | + $countJobs = function($count) use (&$counter) { |
|
| 290 | 290 | $counter += $count; |
| 291 | 291 | }; |
| 292 | 292 | $jobManager->archiveAllJobs(null, null, $countJobs); |
@@ -60,13 +60,13 @@ |
||
| 60 | 60 | $methodName = $request->get('method'); |
| 61 | 61 | |
| 62 | 62 | $jobManager = $this->get('dtc_queue.manager.job'); |
| 63 | - $callback = function ($count) { |
|
| 63 | + $callback = function($count) { |
|
| 64 | 64 | echo json_encode(['count' => $count]); |
| 65 | 65 | echo "\n"; |
| 66 | 66 | flush(); |
| 67 | 67 | }; |
| 68 | 68 | |
| 69 | - $streamingResponse = new StreamedResponse(function () use ($jobManager, $callback, $workerName, $methodName) { |
|
| 69 | + $streamingResponse = new StreamedResponse(function() use ($jobManager, $callback, $workerName, $methodName) { |
|
| 70 | 70 | $total = $jobManager->countLiveJobs($workerName, $methodName); |
| 71 | 71 | echo json_encode(['total' => $total]); |
| 72 | 72 | echo "\n"; |