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:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\PocketImport'
- "@event_dispatcher"
- "@logger"
$import: '@Wallabag\ImportBundle\Import\PocketImport'
wallabag_import.consumer.amqp.readability:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\ReadabilityImport'
- "@event_dispatcher"
- "@logger"
$import: '@Wallabag\ImportBundle\Import\ReadabilityImport'
wallabag_import.consumer.amqp.instapaper:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\InstapaperImport'
- "@event_dispatcher"
- "@logger"
$import: '@Wallabag\ImportBundle\Import\InstapaperImport'
wallabag_import.consumer.amqp.pinboard:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\PinboardImport'
- "@event_dispatcher"
- "@logger"
$import: '@Wallabag\ImportBundle\Import\PinboardImport'
wallabag_import.consumer.amqp.delicious:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\DeliciousImport'
- "@event_dispatcher"
- "@logger"
$import: '@Wallabag\ImportBundle\Import\DeliciousImport'
wallabag_import.consumer.amqp.wallabag_v1:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\WallabagV1Import'
- "@event_dispatcher"
- "@logger"
$import: '@Wallabag\ImportBundle\Import\WallabagV1Import'
wallabag_import.consumer.amqp.wallabag_v2:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\WallabagV2Import'
- "@event_dispatcher"
- "@logger"
$import: '@Wallabag\ImportBundle\Import\WallabagV2Import'
wallabag_import.consumer.amqp.elcurator:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\ElcuratorImport'
- "@event_dispatcher"
- "@logger"
$import: '@Wallabag\ImportBundle\Import\ElcuratorImport'
wallabag_import.consumer.amqp.firefox:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\FirefoxImport'
- "@event_dispatcher"
- "@logger"
$import: '@Wallabag\ImportBundle\Import\FirefoxImport'
wallabag_import.consumer.amqp.chrome:
class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
arguments:
- "@doctrine.orm.entity_manager"
- '@Wallabag\UserBundle\Repository\UserRepository'
- '@Wallabag\ImportBundle\Import\ChromeImport'
- "@event_dispatcher"
- "@logger"
$import: '@Wallabag\ImportBundle\Import\ChromeImport'

View file

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

View file

@ -2,7 +2,7 @@
namespace Wallabag\ImportBundle\Consumer;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@ -20,7 +20,7 @@ abstract class AbstractConsumer
protected $eventDispatcher;
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->userRepository = $userRepository;