Skip to content

Commit 7a6b8b3

Browse files
committed
[transport] Add redis backed transport.
1 parent 83b104e commit 7a6b8b3

27 files changed

+1508
-5
lines changed

composer.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
"enqueue/enqueue": "*@dev",
99
"enqueue/stomp": "*@dev",
1010
"enqueue/amqp-ext": "*@dev",
11+
"enqueue/redis": "*@dev",
1112
"enqueue/fs": "*@dev",
1213
"enqueue/enqueue-bundle": "*@dev",
1314
"enqueue/job-queue": "*@dev",
14-
"enqueue/test": "*@dev"
15-
},
16-
"require-dev": {
15+
"enqueue/test": "*@dev",
16+
1717
"phpunit/phpunit": "^5",
1818
"doctrine/doctrine-bundle": "~1.2",
19+
"predis/predis": "^1.1",
1920
"symfony/monolog-bundle": "^2.8|^3",
2021
"symfony/browser-kit": "^2.8|^3",
2122
"symfony/expression-language": "^2.8|^3",
@@ -46,6 +47,10 @@
4647
"type": "path",
4748
"url": "pkg/amqp-ext"
4849
},
50+
{
51+
"type": "path",
52+
"url": "pkg/redis"
53+
},
4954
{
5055
"type": "path",
5156
"url": "pkg/enqueue-bundle"

docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ services:
66
depends_on:
77
- rabbitmq
88
- mysql
9+
- redis
910
volumes:
1011
- ./:/mqdev
1112
environment:
@@ -29,6 +30,11 @@ services:
2930
- RABBITMQ_DEFAULT_USER=guest
3031
- RABBITMQ_DEFAULT_PASS=guest
3132
- RABBITMQ_DEFAULT_VHOST=mqdev
33+
redis:
34+
image: 'redis:3'
35+
ports:
36+
- "6379:6379"
37+
3238
mysql:
3339
image: mariadb:10
3440
volumes:

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ FROM ubuntu:16.04
44
RUN set -x && \
55
apt-get update && \
66
apt-get install -y --no-install-recommends wget curl openssl ca-certificates nano netcat && \
7-
apt-get install -y --no-install-recommends php php-mysql php-curl php-intl php-mbstring php-zip php-mcrypt php-xdebug php-bcmath php-xml php-amqp
7+
apt-get install -y --no-install-recommends php php-mysql php-redis php-curl php-intl php-mbstring php-zip php-mcrypt php-xdebug php-bcmath php-xml php-amqp
88

99
## confis
1010

phpunit.xml.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
<directory>pkg/fs/Tests</directory>
3434
</testsuite>
3535

36+
<testsuite name="redis-ext">
37+
<directory>pkg/redis-ext/Tests</directory>
38+
</testsuite>
39+
3640
<testsuite name="enqueue-bundle">
3741
<directory>pkg/enqueue-bundle/Tests</directory>
3842
</testsuite>

pkg/amqp-ext/AmqpConnectionFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class AmqpConnectionFactory implements PsrConnectionFactory
2626
* 'read_timeout' => Timeout in for income activity. Note: 0 or greater seconds. May be fractional.
2727
* 'write_timeout' => Timeout in for outcome activity. Note: 0 or greater seconds. May be fractional.
2828
* 'connect_timeout' => Connection timeout. Note: 0 or greater seconds. May be fractional.
29-
* 'persisted' => bool
29+
* 'persisted' => bool, Whether it use single persisted connection or open a new one for every context
30+
* 'lazy' => the connection will be performed as later as possible, if the option set to true
3031
* ].
3132
*
3233
* @param $config

pkg/enqueue/Rpc/Promise.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function getMessage()
5050

5151
return $message;
5252
}
53+
5354
$this->consumer->reject($message, true);
5455
}
5556
}

pkg/fs/FsConsumer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Enqueue\Fs;
44

5+
use Enqueue\Psr\InvalidMessageException;
56
use Enqueue\Psr\PsrConsumer;
67
use Enqueue\Psr\PsrMessage;
78

@@ -118,6 +119,8 @@ public function acknowledge(PsrMessage $message)
118119
*/
119120
public function reject(PsrMessage $message, $requeue = false)
120121
{
122+
InvalidMessageException::assertMessageInstanceOf($message, FsMessage::class);
123+
121124
// do nothing on reject. fs transport always works in auto ack mode
122125

123126
if ($requeue) {

pkg/redis/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*~
2+
/composer.lock
3+
/composer.phar
4+
/phpunit.xml
5+
/vendor/
6+
/.idea/

pkg/redis/.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
sudo: false
2+
3+
git:
4+
depth: 1
5+
6+
language: php
7+
8+
php:
9+
- '5.6'
10+
- '7.0'
11+
12+
cache:
13+
directories:
14+
- $HOME/.composer/cache
15+
16+
install:
17+
- composer self-update
18+
- composer install --prefer-source
19+
20+
script:
21+
- vendor/bin/phpunit --exclude-group=functional

pkg/redis/LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
Copyright (c) 2017 Forma-Pro
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is furnished
9+
to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
THE SOFTWARE.

0 commit comments

Comments
 (0)