forked from wallabag/wallabag
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` -
This commit is contained in:
36
src/Wallabag/ImportBundle/Redis/Producer.php
Normal file
36
src/Wallabag/ImportBundle/Redis/Producer.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Wallabag\ImportBundle\Redis;
|
||||
|
||||
use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;
|
||||
use Simpleue\Queue\RedisQueue;
|
||||
|
||||
/**
|
||||
* This is a proxy class for "Simpleue\Queue\RedisQueue".
|
||||
* It allow us to use the same way to publish a message between RabbitMQ & Redis: publish().
|
||||
*
|
||||
* It implements the ProducerInterface of RabbitMQ (yes it's ugly) so we can have the same
|
||||
* kind of class which implements the same interface.
|
||||
* So we can inject either a RabbitMQ producer or a Redis producer with the same signature
|
||||
*/
|
||||
class Producer implements ProducerInterface
|
||||
{
|
||||
private $queue;
|
||||
|
||||
public function __construct(RedisQueue $queue)
|
||||
{
|
||||
$this->queue = $queue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a message in the Redis queue.
|
||||
*
|
||||
* @param string $msgBody
|
||||
* @param string $routingKey NOT USED
|
||||
* @param array $additionalProperties NOT USED
|
||||
*/
|
||||
public function publish($msgBody, $routingKey = '', $additionalProperties = array())
|
||||
{
|
||||
$this->queue->sendJob($msgBody);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user