diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-09-09 21:02:03 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-09-11 21:58:56 +0200 |
commit | b3437d58ae224121375c99e9288d8b808524e624 (patch) | |
tree | 94ce3446aed4396ba9304b8c97e421eba35e4edf /src/Wallabag/ImportBundle/Command | |
parent | 7f7531171f6e49110b5842f869e37c766a682473 (diff) | |
download | wallabag-b3437d58ae224121375c99e9288d8b808524e624.tar.gz wallabag-b3437d58ae224121375c99e9288d8b808524e624.tar.zst wallabag-b3437d58ae224121375c99e9288d8b808524e624.zip |
Enable Redis async import
- using javibravo/simpleue
- internal config value are now `import_with_redis` & `import_with_rabbit` which are more clear
- if both option are enable rabbit will be choosen
- services imports related to async are now splitted into 2 files: `redis.yml` & `rabbit.yml`
-
Diffstat (limited to 'src/Wallabag/ImportBundle/Command')
-rw-r--r-- | src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php b/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php new file mode 100644 index 00000000..85c5a903 --- /dev/null +++ b/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php | |||
@@ -0,0 +1,41 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\ImportBundle\Command; | ||
4 | |||
5 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
6 | use Symfony\Component\Config\Definition\Exception\Exception; | ||
7 | use Symfony\Component\Console\Input\InputArgument; | ||
8 | use Symfony\Component\Console\Input\InputInterface; | ||
9 | use Symfony\Component\Console\Output\OutputInterface; | ||
10 | use Simpleue\Worker\QueueWorker; | ||
11 | |||
12 | class RedisWorkerCommand extends ContainerAwareCommand | ||
13 | { | ||
14 | protected function configure() | ||
15 | { | ||
16 | $this | ||
17 | ->setName('wallabag:import:redis-worker') | ||
18 | ->setDescription('Launch Redis worker') | ||
19 | ->addArgument('serviceName', InputArgument::REQUIRED, 'Service to use: wallabag_v1, wallabag_v2, pocket or readability') | ||
20 | ; | ||
21 | } | ||
22 | |||
23 | protected function execute(InputInterface $input, OutputInterface $output) | ||
24 | { | ||
25 | $output->writeln('Worker started at: '.(new \DateTime())->format('d-m-Y G:i:s')); | ||
26 | $output->writeln('Waiting for message ...'); | ||
27 | |||
28 | $serviceName = $input->getArgument('serviceName'); | ||
29 | |||
30 | if (!$this->getContainer()->has('wallabag_import.queue.redis.'.$serviceName) || !$this->getContainer()->has('wallabag_import.consumer.redis.'.$serviceName)) { | ||
31 | throw new Exception(sprintf('No queue or consumer found for service name: "%s"', $input->getArgument('serviceName'))); | ||
32 | } | ||
33 | |||
34 | $worker = new QueueWorker( | ||
35 | $this->getContainer()->get('wallabag_import.queue.redis.'.$serviceName), | ||
36 | $this->getContainer()->get('wallabag_import.consumer.redis.'.$serviceName) | ||
37 | ); | ||
38 | |||
39 | $worker->start(); | ||
40 | } | ||
41 | } | ||