aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ImportBundle/Controller')
-rw-r--r--src/Wallabag/ImportBundle/Controller/ImportController.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/Wallabag/ImportBundle/Controller/ImportController.php b/src/Wallabag/ImportBundle/Controller/ImportController.php
index c1486e38..d670746c 100644
--- a/src/Wallabag/ImportBundle/Controller/ImportController.php
+++ b/src/Wallabag/ImportBundle/Controller/ImportController.php
@@ -16,4 +16,58 @@ class ImportController extends Controller
16 'imports' => $this->get('wallabag_import.chain')->getAll(), 16 'imports' => $this->get('wallabag_import.chain')->getAll(),
17 ]); 17 ]);
18 } 18 }
19
20 /**
21 * Display how many messages are queue (both in Redis and RabbitMQ).
22 */
23 public function checkQueueAction()
24 {
25 $nbRedisMessages = null;
26 $nbRabbitMessages = null;
27
28 if ($this->get('craue_config')->get('import_with_rabbitmq')) {
29 $nbRabbitMessages = $this->getTotalMessageInRabbitQueue('pocket')
30 + $this->getTotalMessageInRabbitQueue('readability')
31 + $this->getTotalMessageInRabbitQueue('wallabag_v1')
32 + $this->getTotalMessageInRabbitQueue('wallabag_v2')
33 ;
34 } elseif ($this->get('craue_config')->get('import_with_redis')) {
35 $redis = $this->get('wallabag_core.redis.client');
36
37 $nbRedisMessages = $redis->llen('wallabag.import.pocket')
38 + $redis->llen('wallabag.import.readability')
39 + $redis->llen('wallabag.import.wallabag_v1')
40 + $redis->llen('wallabag.import.wallabag_v2')
41 ;
42 }
43
44 return $this->render('WallabagImportBundle:Import:check_queue.html.twig', [
45 'nbRedisMessages' => $nbRedisMessages,
46 'nbRabbitMessages' => $nbRabbitMessages,
47 ]);
48 }
49
50 /**
51 * Count message in RabbitMQ queue.
52 * It get one message without acking it (so it'll stay in the queue)
53 * which will include the total of *other* messages in the queue.
54 * Adding one to that messages will result in the full total message.
55 *
56 * @param string $importService The import service related: pocket, readability, wallabag_v1 or wallabag_v2
57 *
58 * @return int
59 */
60 private function getTotalMessageInRabbitQueue($importService)
61 {
62 $message = $this
63 ->get('old_sound_rabbit_mq.import_'.$importService.'_consumer')
64 ->getChannel()
65 ->basic_get('wallabag.import.'.$importService);
66
67 if (null === $message) {
68 return 0;
69 }
70
71 return $message->delivery_info['message_count'] + 1;
72 }
19} 73}