Comparing version 5.37.0 to 5.38.0
@@ -24,3 +24,8 @@ "use strict"; | ||
this.opts = Object.assign({ prefix: 'bull' }, opts); | ||
this.connection = new Connection(opts.connection, (0, utils_1.isRedisInstance)(opts.connection), false, opts.skipVersionCheck); | ||
this.connection = new Connection(opts.connection, { | ||
shared: (0, utils_1.isRedisInstance)(opts.connection), | ||
blocking: false, | ||
skipVersionCheck: opts.skipVersionCheck, | ||
skipWaitingForReady: opts.skipWaitingForReady, | ||
}); | ||
this.connection.on('error', (error) => this.emit('error', error)); | ||
@@ -27,0 +32,0 @@ this.connection.on('close', () => { |
@@ -40,3 +40,8 @@ "use strict"; | ||
} | ||
this.connection = new Connection(opts.connection, (0, utils_1.isRedisInstance)(opts.connection), hasBlockingConnection, opts.skipVersionCheck); | ||
this.connection = new Connection(opts.connection, { | ||
shared: (0, utils_1.isRedisInstance)(opts.connection), | ||
blocking: hasBlockingConnection, | ||
skipVersionCheck: opts.skipVersionCheck, | ||
skipWaitingForReady: opts.skipWaitingForReady, | ||
}); | ||
this.connection.on('error', (error) => this.emit('error', error)); | ||
@@ -43,0 +48,0 @@ this.connection.on('close', () => { |
@@ -19,6 +19,5 @@ "use strict"; | ||
class RedisConnection extends events_1.EventEmitter { | ||
constructor(opts, shared = false, blocking = true, skipVersionCheck = false) { | ||
constructor(opts, extraOptions) { | ||
super(); | ||
this.shared = shared; | ||
this.blocking = blocking; | ||
this.extraOptions = extraOptions; | ||
this.capabilities = { | ||
@@ -30,2 +29,4 @@ canDoubleTimeout: false, | ||
this.packageVersion = version_1.version; | ||
// Set extra options defaults | ||
this.extraOptions = Object.assign({ shared: false, blocking: true, skipVersionCheck: false, skipWaitingForReady: false }, extraOptions); | ||
if (!(0, utils_2.isRedisInstance)(opts)) { | ||
@@ -36,3 +37,3 @@ this.checkBlockingOptions(overrideMessage, opts); | ||
} }, opts); | ||
if (this.blocking) { | ||
if (this.extraOptions.blocking) { | ||
this.opts.maxRetriesPerRequest = null; | ||
@@ -57,3 +58,4 @@ } | ||
this.skipVersionCheck = | ||
skipVersionCheck || !!(this.opts && this.opts.skipVersionCheck); | ||
(extraOptions === null || extraOptions === void 0 ? void 0 : extraOptions.skipVersionCheck) || | ||
!!(this.opts && this.opts.skipVersionCheck); | ||
this.handleClientError = (err) => { | ||
@@ -72,3 +74,3 @@ this.emit('error', err); | ||
checkBlockingOptions(msg, options, throwError = false) { | ||
if (this.blocking && options && options.maxRetriesPerRequest) { | ||
if (this.extraOptions.blocking && options && options.maxRetriesPerRequest) { | ||
if (throwError) { | ||
@@ -161,3 +163,5 @@ throw new Error(msg); | ||
this._client.on('ready', this.handleClientReady); | ||
await RedisConnection.waitUntilReady(this._client); | ||
if (!this.extraOptions.skipWaitingForReady) { | ||
await RedisConnection.waitUntilReady(this._client); | ||
} | ||
this.loadCommands(this.packageVersion); | ||
@@ -223,3 +227,3 @@ if (this._client['status'] !== 'end') { | ||
} | ||
if (!this.shared) { | ||
if (!this.extraOptions.shared) { | ||
if (status == 'initializing' || force) { | ||
@@ -226,0 +230,0 @@ // If we have not still connected to Redis, we need to disconnect. |
@@ -111,3 +111,7 @@ "use strict"; | ||
? opts.connection.duplicate({ connectionName }) | ||
: Object.assign(Object.assign({}, opts.connection), { connectionName }), false, true, opts.skipVersionCheck); | ||
: Object.assign(Object.assign({}, opts.connection), { connectionName }), { | ||
shared: false, | ||
blocking: true, | ||
skipVersionCheck: opts.skipVersionCheck, | ||
}); | ||
this.blockingConnection.on('error', error => this.emit('error', error)); | ||
@@ -114,0 +118,0 @@ this.blockingConnection.on('ready', () => setTimeout(() => this.emit('ready'), 0)); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = '5.37.0'; | ||
exports.version = '5.38.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -21,3 +21,8 @@ import { EventEmitter } from 'events'; | ||
this.opts = Object.assign({ prefix: 'bull' }, opts); | ||
this.connection = new Connection(opts.connection, isRedisInstance(opts.connection), false, opts.skipVersionCheck); | ||
this.connection = new Connection(opts.connection, { | ||
shared: isRedisInstance(opts.connection), | ||
blocking: false, | ||
skipVersionCheck: opts.skipVersionCheck, | ||
skipWaitingForReady: opts.skipWaitingForReady, | ||
}); | ||
this.connection.on('error', (error) => this.emit('error', error)); | ||
@@ -24,0 +29,0 @@ this.connection.on('close', () => { |
@@ -37,3 +37,8 @@ import { EventEmitter } from 'events'; | ||
} | ||
this.connection = new Connection(opts.connection, isRedisInstance(opts.connection), hasBlockingConnection, opts.skipVersionCheck); | ||
this.connection = new Connection(opts.connection, { | ||
shared: isRedisInstance(opts.connection), | ||
blocking: hasBlockingConnection, | ||
skipVersionCheck: opts.skipVersionCheck, | ||
skipWaitingForReady: opts.skipWaitingForReady, | ||
}); | ||
this.connection.on('error', (error) => this.emit('error', error)); | ||
@@ -40,0 +45,0 @@ this.connection.on('close', () => { |
@@ -14,4 +14,3 @@ /// <reference types="node" /> | ||
export declare class RedisConnection extends EventEmitter { | ||
private readonly shared; | ||
private readonly blocking; | ||
private readonly extraOptions?; | ||
static minimumVersion: string; | ||
@@ -31,3 +30,8 @@ static recommendedMinimumVersion: string; | ||
private handleClientReady; | ||
constructor(opts?: ConnectionOptions, shared?: boolean, blocking?: boolean, skipVersionCheck?: boolean); | ||
constructor(opts: ConnectionOptions, extraOptions?: { | ||
shared?: boolean; | ||
blocking?: boolean; | ||
skipVersionCheck?: boolean; | ||
skipWaitingForReady?: boolean; | ||
}); | ||
private checkBlockingOptions; | ||
@@ -34,0 +38,0 @@ /** |
@@ -16,6 +16,5 @@ import { __rest } from "tslib"; | ||
export class RedisConnection extends EventEmitter { | ||
constructor(opts, shared = false, blocking = true, skipVersionCheck = false) { | ||
constructor(opts, extraOptions) { | ||
super(); | ||
this.shared = shared; | ||
this.blocking = blocking; | ||
this.extraOptions = extraOptions; | ||
this.capabilities = { | ||
@@ -27,2 +26,4 @@ canDoubleTimeout: false, | ||
this.packageVersion = packageVersion; | ||
// Set extra options defaults | ||
this.extraOptions = Object.assign({ shared: false, blocking: true, skipVersionCheck: false, skipWaitingForReady: false }, extraOptions); | ||
if (!isRedisInstance(opts)) { | ||
@@ -33,3 +34,3 @@ this.checkBlockingOptions(overrideMessage, opts); | ||
} }, opts); | ||
if (this.blocking) { | ||
if (this.extraOptions.blocking) { | ||
this.opts.maxRetriesPerRequest = null; | ||
@@ -54,3 +55,4 @@ } | ||
this.skipVersionCheck = | ||
skipVersionCheck || !!(this.opts && this.opts.skipVersionCheck); | ||
(extraOptions === null || extraOptions === void 0 ? void 0 : extraOptions.skipVersionCheck) || | ||
!!(this.opts && this.opts.skipVersionCheck); | ||
this.handleClientError = (err) => { | ||
@@ -69,3 +71,3 @@ this.emit('error', err); | ||
checkBlockingOptions(msg, options, throwError = false) { | ||
if (this.blocking && options && options.maxRetriesPerRequest) { | ||
if (this.extraOptions.blocking && options && options.maxRetriesPerRequest) { | ||
if (throwError) { | ||
@@ -158,3 +160,5 @@ throw new Error(msg); | ||
this._client.on('ready', this.handleClientReady); | ||
await RedisConnection.waitUntilReady(this._client); | ||
if (!this.extraOptions.skipWaitingForReady) { | ||
await RedisConnection.waitUntilReady(this._client); | ||
} | ||
this.loadCommands(this.packageVersion); | ||
@@ -220,3 +224,3 @@ if (this._client['status'] !== 'end') { | ||
} | ||
if (!this.shared) { | ||
if (!this.extraOptions.shared) { | ||
if (status == 'initializing' || force) { | ||
@@ -223,0 +227,0 @@ // If we have not still connected to Redis, we need to disconnect. |
@@ -108,3 +108,7 @@ import * as fs from 'fs'; | ||
? opts.connection.duplicate({ connectionName }) | ||
: Object.assign(Object.assign({}, opts.connection), { connectionName }), false, true, opts.skipVersionCheck); | ||
: Object.assign(Object.assign({}, opts.connection), { connectionName }), { | ||
shared: false, | ||
blocking: true, | ||
skipVersionCheck: opts.skipVersionCheck, | ||
}); | ||
this.blockingConnection.on('error', error => this.emit('error', error)); | ||
@@ -111,0 +115,0 @@ this.blockingConnection.on('ready', () => setTimeout(() => this.emit('ready'), 0)); |
@@ -35,2 +35,11 @@ import { AdvancedRepeatOptions } from './advanced-options'; | ||
telemetry?: Telemetry; | ||
/** | ||
* Skip waiting for connection ready. | ||
* | ||
* In some instances if you want the queue to fail fast if the connection is | ||
* not ready you can set this to true. This could be useful for testing and when | ||
* adding jobs via HTTP endpoints for example. | ||
* | ||
*/ | ||
skipWaitingForReady?: boolean; | ||
} | ||
@@ -69,6 +78,2 @@ /** | ||
settings?: AdvancedRepeatOptions; | ||
/** | ||
* Telemetry client | ||
*/ | ||
telemetry?: Telemetry; | ||
} | ||
@@ -75,0 +80,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
export declare const version = "5.37.0"; | ||
export declare const version = "5.38.0"; |
@@ -1,2 +0,2 @@ | ||
export const version = '5.37.0'; | ||
export const version = '5.38.0'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "bullmq", | ||
"version": "5.37.0", | ||
"version": "5.38.0", | ||
"description": "Queue for messages and jobs based on Redis", | ||
@@ -5,0 +5,0 @@ "homepage": "https://bullmq.io/", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1955879
31524