Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency redis to v4 #453

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
cache: 'yarn'
Expand Down
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,24 @@ jspm_packages
lib
es

# Created by https://www.toptal.com/developers/gitignore/api/yarn
# Edit at https://www.toptal.com/developers/gitignore?templates=yarn

### yarn ###
# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored

.yarn/*
!.yarn/releases
!.yarn/patches
!.yarn/plugins
!.yarn/sdks
!.yarn/versions

# if you are NOT using Zero-installs, then:
# comment the following lines
#!.yarn/cache

# and uncomment the following lines
# .pnp.*

# End of https://www.toptal.com/developers/gitignore/api/yarn
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"express": "^4.17.3",
"redis": "^3.1.2"
"redis": "^4.5.1"
},
"peerDependencies": {
"graphql": ">=16.0.0",
Expand All @@ -56,8 +56,9 @@
}
},
"devDependencies": {
"@4c/babel-preset": "^10.2.1",
"@4c/babel-preset": "^9.1.0",
"@4c/cli": "^3.0.1",
"@4c/graphql-relay-subscription": "^0.4.0",
"@4c/jest-preset": "^1.8.1",
"@4c/prettier-config": "^1.1.0",
"@4c/tsconfig": "^0.4.1",
Expand All @@ -67,7 +68,6 @@
"@types/express": "^4.17.14",
"@types/jest": "^27.5.2",
"@types/jsonwebtoken": "^9.0.0",
"@types/redis": "^2.8.32",
"@typescript-eslint/eslint-plugin": "^5.46.0",
"@typescript-eslint/parser": "^5.46.0",
"babel-jest": "^27.5.1",
Expand All @@ -77,16 +77,15 @@
"eslint-config-4catalyzer-typescript": "^3.3.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.1.7",
"eslint-plugin-jest": "^26.9.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-prettier": "^4.2.1",
"graphql": "^16.6.0",
"graphql-relay": "^0.10.0",
"@4c/graphql-relay-subscription": "^0.4.0",
"hookem": "^3.0.4",
"hookem": "^2.0.1",
"jest": "^27.5.1",
"jsonwebtoken": "^9.0.0",
"lint-staged": "^13.1.0",
"lint-staged": "^12.5.0",
"prettier": "^2.8.1",
"redis-mock": "^0.56.3",
"semantic-release": "^19.0.5",
Expand All @@ -97,7 +96,7 @@
"utility-types": "^3.10.0"
},
"engines": {
"node": ">=v12"
"node": ">=v16"
},
"bugs": {
"url": "https://github.com/4Catalyzer/graphql-subscription-server/issues"
Expand Down
12 changes: 6 additions & 6 deletions src/RedisSubscriber.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { promisify } from 'util';

import redis from 'redis';

import { AsyncQueue, map } from './AsyncUtils';
import { CreateLogger, Logger, noopCreateLogger } from './Logger';
import type { Subscriber } from './Subscriber';
import { createClient, RedisClientOptions } from '@redis/client';

type Channel = string;

export type RedisConfigOptions = redis.ClientOpts & {
export type RedisConfigOptions = RedisClientOptions & {
parseMessage?: (msg: string) => any;
createLogger?: CreateLogger;
};
Expand All @@ -21,7 +21,7 @@ export default class RedisSubscriber<
TOptions extends RedisSubscriberOptions = RedisSubscriberOptions,
> implements Subscriber<TOptions>
{
redis: redis.RedisClient;
redis: ReturnType<typeof createClient>;

_parseMessage: ((msg: string) => any) | null | undefined;

Expand All @@ -37,12 +37,12 @@ export default class RedisSubscriber<
...redisConfig
}: RedisConfigOptions = {}) {
this.log = createLogger('RedisSubscriber');
this.redis = redis.createClient(redisConfig);
this.redis = createClient(redisConfig);
this._queues = new Map();
this._channels = new Set();
this._parseMessage = parseMessage;

this.redis.on('message', (channel, message) => {
this.redis.on('message', (channel: string, message: any) => {
this.log('silly', 'message received', { channel, message });
const queues = this._queues.get(channel);
if (!queues) {
Expand Down Expand Up @@ -114,7 +114,7 @@ export default class RedisSubscriber<
async close() {
await promisify(this.redis.quit).call(this.redis);
this.log('silly', 'closed', {
numQueus: this._queues.size,
numQueues: this._queues.size,
numChannels: this._channels.size,
});
}
Expand Down
2 changes: 1 addition & 1 deletion test/RedisSubscriber.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('RedisSubscriber', () => {
"message": "closed",
"meta": Object {
"numChannels": 0,
"numQueus": 0,
"numQueues": 0,
},
},
]
Expand Down
Loading