Skip to content

Commit

Permalink
fix: default opts
Browse files Browse the repository at this point in the history
  • Loading branch information
manast committed Sep 1, 2019
1 parent a4e1cae commit 333c73b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
10 changes: 4 additions & 6 deletions src/classes/queue-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ export class QueueBase extends EventEmitter {
constructor(protected name: string, public opts: QueueBaseOptions = {}) {
super();

this.opts = Object.assign(
{
prefix: 'bull',
},
opts,
);
this.opts = {
prefix: 'bull',
...opts,
};

this.connection = new RedisConnection(opts.connection);
this.initializing = this.connection.init();
Expand Down
19 changes: 6 additions & 13 deletions src/classes/queue-scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,8 @@ const MAX_TIMEOUT_MS = Math.pow(2, 31) - 1; // 32 bit signed
export class QueueScheduler extends QueueBase {
private nextTimestamp = Number.MAX_VALUE;

constructor(protected name: string, opts?: QueueSchedulerOptions) {
super(name, opts);

this.opts = Object.assign(this.opts, {
maxStalledCount: 1,
stalledInterval: 30000,
});
constructor(protected name: string, opts: QueueSchedulerOptions = {}) {
super(name, { maxStalledCount: 1, stalledInterval: 30000, ...opts });
}

async init() {
Expand Down Expand Up @@ -111,16 +106,14 @@ export class QueueScheduler extends QueueBase {

const [failed, stalled] = await Scripts.moveStalledJobsToWait(this);

failed.forEach((jobId: string) => {
failed.forEach((jobId: string) =>
this.emit(
'failed',
jobId,
new Error('job stalled more than allowable limit'),
'active',
);
});
stalled.forEach((jobId: string) => {
this.emit('stalled', jobId);
});
),
);
stalled.forEach((jobId: string) => this.emit('stalled', jobId, 'active'));
}
}

0 comments on commit 333c73b

Please sign in to comment.