Skip to content

Commit

Permalink
Merge pull request #237 from arsonik/patch-1
Browse files Browse the repository at this point in the history
Redis Cluster to be used in types, Dependencies update ...
  • Loading branch information
davidyaha authored Sep 2, 2020
2 parents 39a34ed + d15b99c commit 659bde2
Show file tree
Hide file tree
Showing 16 changed files with 2,236 additions and 1,276 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
src/test
dist
11 changes: 11 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ dist
coverage
typings
npm-debug.log
.nyc_output
6 changes: 6 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ui": "bdd",
"exit": true,
"check-leaks": true,
"require": ["ts-node/register"]
}
7 changes: 7 additions & 0 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "@istanbuljs/nyc-config-typescript",
"all": false,
"include": ["src/**"],
"exclude": ["src/test/**"],
"check-coverage": true
}
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ cache:
directories:
- node_modules

before_install:
- 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

install:
- npm install

services:
- docker
- redis-server

28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ const pubsub = new RedisPubSub({
});
```

**Also works with your Redis Cluster**

```javascript
import { RedisPubSub } from 'graphql-redis-subscriptions';
import { Cluster } from 'ioredis';

const cluster = new Cluster(REDIS_NODES); // like: [{host: 'ipOrHost', port: 1234}, ...]
const pubsub = new RedisPubSub({
...,
publisher: cluster,
subscriber: cluster
});
```


You can learn more on the `ioredis` package [here](https://github.com/luin/ioredis).

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

## Tests

### Spin a Redis in docker server and cluster
Please refer to https://github.com/Grokzen/docker-redis-cluster documentation to start a cluster
```shell script
$ docker run --rm -p 6379:6379 redis:alpine
$ 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
```

### Test
```shell script
npm run test
```
Loading

0 comments on commit 659bde2

Please sign in to comment.