Skip to content

Commit 396c388

Browse files
committed
redis cluster, docs, updates dependencies …
1 parent 898ec7d commit 396c388

File tree

8 files changed

+412
-559
lines changed

8 files changed

+412
-559
lines changed

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)