Autowire Redis and RabbitMQ services

This commit is contained in:
Yassine Guedidi 2022-04-30 20:12:47 +02:00
parent e856c06d39
commit 1c479d6b97
3 changed files with 41 additions and 122 deletions

View file

@ -8,80 +8,49 @@ services:
wallabag_import.consumer.amqp.pocket: wallabag_import.consumer.amqp.pocket:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\PocketImport'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\PocketImport'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.readability: wallabag_import.consumer.amqp.readability:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\ReadabilityImport'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\ReadabilityImport'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.instapaper: wallabag_import.consumer.amqp.instapaper:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\InstapaperImport'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\InstapaperImport'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.pinboard: wallabag_import.consumer.amqp.pinboard:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\PinboardImport'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\PinboardImport'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.delicious: wallabag_import.consumer.amqp.delicious:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\DeliciousImport'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\DeliciousImport'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.wallabag_v1: wallabag_import.consumer.amqp.wallabag_v1:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\WallabagV1Import'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\WallabagV1Import'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.wallabag_v2: wallabag_import.consumer.amqp.wallabag_v2:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\WallabagV2Import'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\WallabagV2Import'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.elcurator: wallabag_import.consumer.amqp.elcurator:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\ElcuratorImport'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\ElcuratorImport'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.firefox: wallabag_import.consumer.amqp.firefox:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\FirefoxImport'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\FirefoxImport'
- "@event_dispatcher"
- "@logger"
wallabag_import.consumer.amqp.chrome: wallabag_import.consumer.amqp.chrome:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\ChromeImport'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\ChromeImport'
- "@event_dispatcher"
- "@logger"

View file

@ -9,8 +9,7 @@ services:
wallabag_import.queue.redis.readability: wallabag_import.queue.redis.readability:
class: Simpleue\Queue\RedisQueue class: Simpleue\Queue\RedisQueue
arguments: arguments:
- '@Predis\Client' $queueName: "wallabag.import.readability"
- "wallabag.import.readability"
wallabag_import.producer.redis.readability: wallabag_import.producer.redis.readability:
class: Wallabag\ImportBundle\Redis\Producer class: Wallabag\ImportBundle\Redis\Producer
@ -20,18 +19,13 @@ services:
wallabag_import.consumer.redis.readability: wallabag_import.consumer.redis.readability:
class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\ReadabilityImport'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\ReadabilityImport'
- "@event_dispatcher"
- "@logger"
# instapaper # instapaper
wallabag_import.queue.redis.instapaper: wallabag_import.queue.redis.instapaper:
class: Simpleue\Queue\RedisQueue class: Simpleue\Queue\RedisQueue
arguments: arguments:
- '@Predis\Client' $queueName: "wallabag.import.instapaper"
- "wallabag.import.instapaper"
wallabag_import.producer.redis.instapaper: wallabag_import.producer.redis.instapaper:
class: Wallabag\ImportBundle\Redis\Producer class: Wallabag\ImportBundle\Redis\Producer
@ -41,18 +35,13 @@ services:
wallabag_import.consumer.redis.instapaper: wallabag_import.consumer.redis.instapaper:
class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\InstapaperImport'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\InstapaperImport'
- "@event_dispatcher"
- "@logger"
# pinboard # pinboard
wallabag_import.queue.redis.pinboard: wallabag_import.queue.redis.pinboard:
class: Simpleue\Queue\RedisQueue class: Simpleue\Queue\RedisQueue
arguments: arguments:
- '@Predis\Client' $queueName: "wallabag.import.pinboard"
- "wallabag.import.pinboard"
wallabag_import.producer.redis.pinboard: wallabag_import.producer.redis.pinboard:
class: Wallabag\ImportBundle\Redis\Producer class: Wallabag\ImportBundle\Redis\Producer
@ -62,18 +51,13 @@ services:
wallabag_import.consumer.redis.pinboard: wallabag_import.consumer.redis.pinboard:
class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\PinboardImport'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\PinboardImport'
- "@event_dispatcher"
- "@logger"
# delicious # delicious
wallabag_import.queue.redis.delicious: wallabag_import.queue.redis.delicious:
class: Simpleue\Queue\RedisQueue class: Simpleue\Queue\RedisQueue
arguments: arguments:
- '@Predis\Client' $queueName: "wallabag.import.delicious"
- "wallabag.import.delicious"
wallabag_import.producer.redis.delicious: wallabag_import.producer.redis.delicious:
class: Wallabag\ImportBundle\Redis\Producer class: Wallabag\ImportBundle\Redis\Producer
@ -83,18 +67,13 @@ services:
wallabag_import.consumer.redis.delicious: wallabag_import.consumer.redis.delicious:
class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\DeliciousImport'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\DeliciousImport'
- "@event_dispatcher"
- "@logger"
# pocket # pocket
wallabag_import.queue.redis.pocket: wallabag_import.queue.redis.pocket:
class: Simpleue\Queue\RedisQueue class: Simpleue\Queue\RedisQueue
arguments: arguments:
- '@Predis\Client' $queueName: "wallabag.import.pocket"
- "wallabag.import.pocket"
wallabag_import.producer.redis.pocket: wallabag_import.producer.redis.pocket:
class: Wallabag\ImportBundle\Redis\Producer class: Wallabag\ImportBundle\Redis\Producer
@ -104,18 +83,13 @@ services:
wallabag_import.consumer.redis.pocket: wallabag_import.consumer.redis.pocket:
class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\PocketImport'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\PocketImport'
- "@event_dispatcher"
- "@logger"
# wallabag v1 # wallabag v1
wallabag_import.queue.redis.wallabag_v1: wallabag_import.queue.redis.wallabag_v1:
class: Simpleue\Queue\RedisQueue class: Simpleue\Queue\RedisQueue
arguments: arguments:
- '@Predis\Client' $queueName: "wallabag.import.wallabag_v1"
- "wallabag.import.wallabag_v1"
wallabag_import.producer.redis.wallabag_v1: wallabag_import.producer.redis.wallabag_v1:
class: Wallabag\ImportBundle\Redis\Producer class: Wallabag\ImportBundle\Redis\Producer
@ -125,18 +99,13 @@ services:
wallabag_import.consumer.redis.wallabag_v1: wallabag_import.consumer.redis.wallabag_v1:
class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\WallabagV1Import'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\WallabagV1Import'
- "@event_dispatcher"
- "@logger"
# wallabag v2 # wallabag v2
wallabag_import.queue.redis.wallabag_v2: wallabag_import.queue.redis.wallabag_v2:
class: Simpleue\Queue\RedisQueue class: Simpleue\Queue\RedisQueue
arguments: arguments:
- '@Predis\Client' $queueName: "wallabag.import.wallabag_v2"
- "wallabag.import.wallabag_v2"
wallabag_import.producer.redis.wallabag_v2: wallabag_import.producer.redis.wallabag_v2:
class: Wallabag\ImportBundle\Redis\Producer class: Wallabag\ImportBundle\Redis\Producer
@ -146,18 +115,13 @@ services:
wallabag_import.consumer.redis.wallabag_v2: wallabag_import.consumer.redis.wallabag_v2:
class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\WallabagV2Import'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\WallabagV2Import'
- "@event_dispatcher"
- "@logger"
# elcurator # elcurator
wallabag_import.queue.redis.elcurator: wallabag_import.queue.redis.elcurator:
class: Simpleue\Queue\RedisQueue class: Simpleue\Queue\RedisQueue
arguments: arguments:
- '@Predis\Client' $queueName: "wallabag.import.elcurator"
- "wallabag.import.elcurator"
wallabag_import.producer.redis.elcurator: wallabag_import.producer.redis.elcurator:
class: Wallabag\ImportBundle\Redis\Producer class: Wallabag\ImportBundle\Redis\Producer
@ -167,18 +131,13 @@ services:
wallabag_import.consumer.redis.elcurator: wallabag_import.consumer.redis.elcurator:
class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\ElcuratorImport'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\ElcuratorImport'
- "@event_dispatcher"
- "@logger"
# firefox # firefox
wallabag_import.queue.redis.firefox: wallabag_import.queue.redis.firefox:
class: Simpleue\Queue\RedisQueue class: Simpleue\Queue\RedisQueue
arguments: arguments:
- '@Predis\Client' $queueName: "wallabag.import.firefox"
- "wallabag.import.firefox"
wallabag_import.producer.redis.firefox: wallabag_import.producer.redis.firefox:
class: Wallabag\ImportBundle\Redis\Producer class: Wallabag\ImportBundle\Redis\Producer
@ -188,18 +147,13 @@ services:
wallabag_import.consumer.redis.firefox: wallabag_import.consumer.redis.firefox:
class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\FirefoxImport'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\FirefoxImport'
- "@event_dispatcher"
- "@logger"
# chrome # chrome
wallabag_import.queue.redis.chrome: wallabag_import.queue.redis.chrome:
class: Simpleue\Queue\RedisQueue class: Simpleue\Queue\RedisQueue
arguments: arguments:
- '@Predis\Client' $queueName: "wallabag.import.chrome"
- "wallabag.import.chrome"
wallabag_import.producer.redis.chrome: wallabag_import.producer.redis.chrome:
class: Wallabag\ImportBundle\Redis\Producer class: Wallabag\ImportBundle\Redis\Producer
@ -209,8 +163,4 @@ services:
wallabag_import.consumer.redis.chrome: wallabag_import.consumer.redis.chrome:
class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer
arguments: arguments:
- "@doctrine.orm.entity_manager" $import: '@Wallabag\ImportBundle\Import\ChromeImport'
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\ChromeImport'
- "@event_dispatcher"
- "@logger"

View file

@ -2,7 +2,7 @@
namespace Wallabag\ImportBundle\Consumer; namespace Wallabag\ImportBundle\Consumer;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger; use Psr\Log\NullLogger;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@ -20,7 +20,7 @@ abstract class AbstractConsumer
protected $eventDispatcher; protected $eventDispatcher;
protected $logger; protected $logger;
public function __construct(EntityManager $em, UserRepository $userRepository, AbstractImport $import, EventDispatcherInterface $eventDispatcher, LoggerInterface $logger = null) public function __construct(EntityManagerInterface $em, UserRepository $userRepository, AbstractImport $import, EventDispatcherInterface $eventDispatcher, LoggerInterface $logger = null)
{ {
$this->em = $em; $this->em = $em;
$this->userRepository = $userRepository; $this->userRepository = $userRepository;