Skip to content

Commit 4636abd

Browse files
committed
fix: 初始化实例时检查options
1 parent 37d9fd1 commit 4636abd

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

lib/consumer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class Consumer extends EventEmitter {
2727
constructor(options) {
2828
super();
2929

30+
options = options || {};
3031
if (!options.queue) throw new Error('missing queue name');
3132

3233
this._redisPull = utils.createRedisClient(options.redis);

lib/monitor.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class Monitor extends EventEmitter {
7272
constructor(options) {
7373
super();
7474

75+
options = options || {};
76+
7577
this._redis = utils.createRedisClient(options.redis);
7678
this.name = utils.generateClientId('monitor');
7779
this._redisPrefix = (options.redis && options.redis.prefix) || '';

lib/producer.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class Producer extends EventEmitter {
2727
constructor(options) {
2828
super();
2929

30+
options = options || {};
3031
if (!options.queue) throw new Error('missing queue name');
3132

3233
this._redis = utils.createRedisClient(options.redis);
@@ -47,12 +48,12 @@ class Producer extends EventEmitter {
4748

4849
const callbackKey = utils.getCallbackKey(this._redisPrefix, this.queue, this.name);
4950
this._redisSub.subscribe(callbackKey, (channel, count) => {
50-
this._debug('on subscribe: chennel=%s, count=%s', channel, count);
51+
this._debug('on subscribe: channel=%s, count=%s', channel, count);
5152
this.emit('start');
5253
});
5354

54-
this._redisSub.on('message', (chennel, message) => {
55-
this._debug('on reply: %s -> %s', chennel, message);
55+
this._redisSub.on('message', (channel, message) => {
56+
this._debug('on reply: %s -> %s', channel, message);
5657

5758
// msg: success => id,s,data error => id,e,data
5859
const info = utils.splitString(message, ',', 3);

0 commit comments

Comments
 (0)