diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2016-09-19 07:15:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-19 07:15:40 +0200 |
commit | da18a4682f124b02278860d23ac1d59dee995277 (patch) | |
tree | eabbe9da7203eea41e0cb0ec3c26b9b6599cf58f /src/Wallabag/ImportBundle/Redis | |
parent | 0ed8ce55b5caf2c88e8330afa83abef6c4aac9a4 (diff) | |
parent | 59b97fae996d8307b9d957d210d46200f6d206bf (diff) | |
download | wallabag-da18a4682f124b02278860d23ac1d59dee995277.tar.gz wallabag-da18a4682f124b02278860d23ac1d59dee995277.tar.zst wallabag-da18a4682f124b02278860d23ac1d59dee995277.zip |
Merge pull request #1941 from wallabag/v2-asynchronous-jobs
Use asynchronous jobs for imports
Diffstat (limited to 'src/Wallabag/ImportBundle/Redis')
-rw-r--r-- | src/Wallabag/ImportBundle/Redis/Producer.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Wallabag/ImportBundle/Redis/Producer.php b/src/Wallabag/ImportBundle/Redis/Producer.php new file mode 100644 index 00000000..fedc3e57 --- /dev/null +++ b/src/Wallabag/ImportBundle/Redis/Producer.php | |||
@@ -0,0 +1,36 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\ImportBundle\Redis; | ||
4 | |||
5 | use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface; | ||
6 | use Simpleue\Queue\RedisQueue; | ||
7 | |||
8 | /** | ||
9 | * This is a proxy class for "Simpleue\Queue\RedisQueue". | ||
10 | * It allow us to use the same way to publish a message between RabbitMQ & Redis: publish(). | ||
11 | * | ||
12 | * It implements the ProducerInterface of RabbitMQ (yes it's ugly) so we can have the same | ||
13 | * kind of class which implements the same interface. | ||
14 | * So we can inject either a RabbitMQ producer or a Redis producer with the same signature | ||
15 | */ | ||
16 | class Producer implements ProducerInterface | ||
17 | { | ||
18 | private $queue; | ||
19 | |||
20 | public function __construct(RedisQueue $queue) | ||
21 | { | ||
22 | $this->queue = $queue; | ||
23 | } | ||
24 | |||
25 | /** | ||
26 | * Publish a message in the Redis queue. | ||
27 | * | ||
28 | * @param string $msgBody | ||
29 | * @param string $routingKey NOT USED | ||
30 | * @param array $additionalProperties NOT USED | ||
31 | */ | ||
32 | public function publish($msgBody, $routingKey = '', $additionalProperties = array()) | ||
33 | { | ||
34 | $this->queue->sendJob($msgBody); | ||
35 | } | ||
36 | } | ||