Skip to content

Commit

Permalink
fix(scheduler): duplicate connections fixes #174
Browse files Browse the repository at this point in the history
  • Loading branch information
manast authored Apr 10, 2020
1 parent 06d3d4f commit 011b8ac
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/classes/queue-scheduler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { QueueSchedulerOptions } from '../interfaces';
import { array2obj } from '../utils';
import { array2obj, isRedisInstance } from '../utils';
import { QueueBase } from './';
import { Scripts } from './scripts';
import IORedis = require('ioredis');
Expand All @@ -26,8 +26,18 @@ export class QueueScheduler extends QueueBase {
private nextTimestamp = Number.MAX_VALUE;
private isBlocked = false;

constructor(name: string, opts: QueueSchedulerOptions = {}) {
super(name, { maxStalledCount: 1, stalledInterval: 30000, ...opts });
constructor(
name: string,
{ connection, ...opts }: QueueSchedulerOptions = {},
) {
super(name, {
maxStalledCount: 1,
stalledInterval: 30000,
...opts,
connection: isRedisInstance(connection)
? (<IORedis.Redis>connection).duplicate()
: connection,
});

// tslint:disable: no-floating-promises
this.run();
Expand Down

0 comments on commit 011b8ac

Please sign in to comment.