Skip to content

Commit 659bde2

Browse files
authored
Merge pull request #237 from arsonik/patch-1
Redis Cluster to be used in types, Dependencies update ...
2 parents 39a34ed + d15b99c commit 659bde2

16 files changed

+2236
-1276
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
src/test
3+
dist

.eslintrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
plugins: [
5+
'@typescript-eslint',
6+
],
7+
extends: [
8+
'eslint:recommended',
9+
'plugin:@typescript-eslint/recommended',
10+
],
11+
};

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ dist
44
coverage
55
typings
66
npm-debug.log
7+
.nyc_output

.mocharc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"ui": "bdd",
3+
"exit": true,
4+
"check-leaks": true,
5+
"require": ["ts-node/register"]
6+
}

.nycrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "@istanbuljs/nyc-config-typescript",
3+
"all": false,
4+
"include": ["src/**"],
5+
"exclude": ["src/test/**"],
6+
"check-coverage": true
7+
}

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ cache:
77
directories:
88
- node_modules
99

10+
before_install:
11+
- docker run -d -p 127.0.0.1:7000:7000 -p 127.0.0.1:7001:7001 -p 127.0.0.1:7002:7002 -p 127.0.0.1:7003:7003 -p 127.0.0.1:7004:7004 -p 127.0.0.1:7005:7005 grokzen/redis-cluster:latest
12+
1013
install:
1114
- npm install
1215

1316
services:
17+
- docker
1418
- redis-server
19+

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,21 @@ const pubsub = new RedisPubSub({
133133
});
134134
```
135135

136+
**Also works with your Redis Cluster**
137+
138+
```javascript
139+
import { RedisPubSub } from 'graphql-redis-subscriptions';
140+
import { Cluster } from 'ioredis';
141+
142+
const cluster = new Cluster(REDIS_NODES); // like: [{host: 'ipOrHost', port: 1234}, ...]
143+
const pubsub = new RedisPubSub({
144+
...,
145+
publisher: cluster,
146+
subscriber: cluster
147+
});
148+
```
149+
150+
136151
You can learn more on the `ioredis` package [here](https://github.com/luin/ioredis).
137152

138153
## Using a custom reviver
@@ -231,3 +246,16 @@ The subscription string that Redis will receive will be `comments.added.graphql-
231246
This subscription string is much more specific and means the the filtering required for this type of subscription is not needed anymore.
232247
This is one step towards lifting the load off of the GraphQL API server regarding subscriptions.
233248

249+
## Tests
250+
251+
### Spin a Redis in docker server and cluster
252+
Please refer to https://github.com/Grokzen/docker-redis-cluster documentation to start a cluster
253+
```shell script
254+
$ docker run --rm -p 6379:6379 redis:alpine
255+
$ export REDIS_CLUSTER_IP=0.0.0.0; docker run -e "IP=0.0.0.0" --rm -p 7000:7000 -p 7001:7001 -p 7002:7002 -p 7003:7003 -p 7004:7004 -p 7005:7005 grokzen/redis-cluster
256+
```
257+
258+
### Test
259+
```shell script
260+
npm run test
261+
```

0 commit comments

Comments
 (0)