Skip to content

Commit b9dcbee

Browse files
Boris Dorofeevnodkz
Boris Dorofeev
authored andcommitted
feat: update bullmq to 1.91.1 & fix typing for indirectly updated ioredis
relates: #72
1 parent ae6cd53 commit b9dcbee

File tree

7 files changed

+165
-90
lines changed

7 files changed

+165
-90
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"homepage": "https://github.com/graphql-compose/graphql-compose-bullmq",
2727
"peerDependencies": {
28-
"bullmq": "^1.14.4",
28+
"bullmq": "^1.91.1",
2929
"graphql-compose": "^7.15.0 || ^8.0.0 || ^9.0.0"
3030
},
3131
"devDependencies": {
@@ -37,7 +37,7 @@
3737
"@types/node-fetch": "2.5.10",
3838
"@typescript-eslint/eslint-plugin": "4.25.0",
3939
"@typescript-eslint/parser": "4.25.0",
40-
"bullmq": "1.28.0",
40+
"bullmq": "1.91.1",
4141
"cpx": "^1.5.0",
4242
"cross-env": "7.0.3",
4343
"eslint": "7.27.0",

src/definitions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ObjectTypeComposer } from 'graphql-compose';
2-
import IORedis, { RedisOptions } from 'ioredis';
2+
import Redis, { RedisOptions } from 'ioredis';
33

44
export type Options = {
55
typePrefix: string;
@@ -8,5 +8,5 @@ export type Options = {
88
name?: string;
99
prefix?: string;
1010
};
11-
redis?: RedisOptions | IORedis.Redis;
11+
redis?: RedisOptions | Redis;
1212
};

src/helpers/fixDelayStream.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export async function addFixRecordToDelayStream(
3333

3434
const streamName = fullQueueName + ':delay';
3535

36-
const first = await redis.xrange(streamName, '-', '+', 'count', 1);
37-
const last = await redis.xrevrange(streamName, '+', '-', 'count', 1);
36+
const first = await redis.xrange(streamName, '-', '+', 'COUNT', 1);
37+
const last = await redis.xrevrange(streamName, '+', '-', 'COUNT', 1);
3838
const defaultRec = {
3939
id: '0-0',
4040
nextTimestamp: '',
@@ -53,6 +53,10 @@ export async function addFixRecordToDelayStream(
5353
}
5454
}
5555

56+
if (!fixLastId) {
57+
throw new Error(`The command <xadd ${streamName}> returns a Null reply.`);
58+
}
59+
5660
return {
5761
first: readRecords(first),
5862
last: readRecords(last),

src/helpers/getBullConnection.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { Options } from './../definitions';
22
import Redis from 'ioredis';
33

4-
const connectionMap = new Map<Options['redis'], Redis.Redis>();
4+
const connectionMap = new Map<Options['redis'], Redis>();
55

6-
export function getBullConnection(opts?: Options): Redis.Redis {
6+
export function getBullConnection(opts?: Options): Redis {
77
const optsRedis = opts?.redis;
88
let connection = connectionMap.get(optsRedis);
99
if (connection) {
1010
return connection;
1111
}
1212

1313
if (optsRedis instanceof Redis || optsRedis?.constructor?.name === 'Redis') {
14-
connection = optsRedis as Redis.Redis;
14+
connection = optsRedis as Redis;
1515
} else if (optsRedis) {
1616
connection = new Redis(optsRedis);
1717
} else {

src/helpers/memoryUsage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import fs from 'fs';
77

88
let commandDefined = false;
99

10-
async function defineCommand(redis: Redis.Redis) {
10+
async function defineCommand(redis: Redis) {
1111
const readFile = util.promisify(fs.readFile);
1212
const lua = await readFile(path.join(__dirname, 'zsetKeysMemoryUsage.lua'));
1313

src/helpers/queueEventsListen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function createAsyncIterator<T = any>(
6363
pushValue(event);
6464
};
6565

66-
queueEvents.on(eventName, handler);
66+
queueEvents.on(eventName as any, handler);
6767

6868
function release() {
6969
if (listening) {

0 commit comments

Comments
 (0)