Comparing version 1.6.1 to 1.6.2
@@ -0,1 +1,10 @@ | ||
## [1.6.2](https://github.com/taskforcesh/bullmq/compare/v1.6.1...v1.6.2) (2019-12-16) | ||
### Bug Fixes | ||
* change default QueueEvents lastEventId to $ ([3c5b01d](https://github.com/taskforcesh/bullmq/commit/3c5b01d16ee1442f5802a0fe4e7675c14f7a7f1f)) | ||
* ensure QE ready before adding test events ([fd190f4](https://github.com/taskforcesh/bullmq/commit/fd190f4be792b03273481c8aaf73be5ca42663d1)) | ||
* explicitly test the behavior of .on and .once ([ea11087](https://github.com/taskforcesh/bullmq/commit/ea11087b292d9325105707b53f92ac61c334a147)) | ||
## [1.6.1](https://github.com/taskforcesh/bullmq/compare/v1.6.0...v1.6.1) (2019-12-16) | ||
@@ -2,0 +11,0 @@ |
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
import { Job } from './'; | ||
import { QueueEvents, Job } from './'; | ||
import { JobsOptions, QueueOptions, RepeatOptions, QueueEventsOptions, QueueSchedulerOptions, WorkerOptions, Processor } from '../interfaces'; | ||
@@ -11,5 +11,5 @@ declare type CommonOptions = QueueSchedulerOptions & QueueOptions & WorkerOptions & QueueEventsOptions; | ||
name: string; | ||
queueEvents: QueueEvents; | ||
private opts; | ||
private readonly queue; | ||
private queueEvents; | ||
private worker; | ||
@@ -16,0 +16,0 @@ private queueScheduler; |
@@ -18,3 +18,3 @@ "use strict"; | ||
const key = this.keys.events; | ||
let id = opts.lastEventId || '0-0'; | ||
let id = opts.lastEventId || '$'; | ||
while (!this.closing) { | ||
@@ -21,0 +21,0 @@ try { |
@@ -299,19 +299,33 @@ /*eslint-env node */ | ||
}); | ||
mocha_1.it('should listen to global events', function (done) { | ||
let state; | ||
queue.on('global:waiting', function () { | ||
chai_1.expect(state).to.be.undefined; | ||
state = 'waiting'; | ||
}); | ||
queue.once('global:active', function () { | ||
chai_1.expect(state).to.be.equal('waiting'); | ||
state = 'active'; | ||
}); | ||
queue.once('global:completed', async function () { | ||
chai_1.expect(state).to.be.equal('active'); | ||
done(); | ||
}); | ||
queue.add('test', {}); | ||
queue.process(async () => { }); | ||
mocha_1.it('should listen to global events with .once', async function () { | ||
const events = []; | ||
queue.once('global:waiting', () => events.push('waiting')); | ||
queue.once('global:active', () => events.push('active')); | ||
queue.once('global:completed', () => events.push('completed')); | ||
await queue.queueEvents.waitUntilReady(); | ||
await queue.add('test', {}); | ||
await queue.add('test', {}); | ||
await queue.process(() => null); | ||
await utils_1.delay(50); | ||
chai_1.expect(events).to.eql(['waiting', 'active', 'completed']); | ||
}); | ||
mocha_1.it('should listen to global events with .on', async function () { | ||
const events = []; | ||
queue.on('global:waiting', () => events.push('waiting')); | ||
queue.on('global:active', () => events.push('active')); | ||
queue.on('global:completed', () => events.push('completed')); | ||
await queue.queueEvents.waitUntilReady(); | ||
await queue.add('test', {}); | ||
await queue.add('test', {}); | ||
await queue.process(() => null); | ||
await utils_1.delay(50); | ||
chai_1.expect(events).to.eql([ | ||
'waiting', | ||
'waiting', | ||
'active', | ||
'completed', | ||
'active', | ||
'completed', | ||
]); | ||
}); | ||
}); | ||
@@ -363,2 +377,10 @@ mocha_1.describe('Pause', function () { | ||
let isPaused = false, isResumed = true, first = true; | ||
queue.on('global:paused', async () => { | ||
isPaused = false; | ||
await queue.resume(); | ||
}); | ||
queue.on('global:resumed', () => { | ||
isResumed = true; | ||
}); | ||
await queue.queueEvents.waitUntilReady(); | ||
const processPromise = new Promise((resolve, reject) => { | ||
@@ -387,9 +409,2 @@ process = async (job) => { | ||
queue.add('test', { foo: 'paused' }); | ||
queue.on('global:paused', async () => { | ||
isPaused = false; | ||
await queue.resume(); | ||
}); | ||
queue.on('global:resumed', () => { | ||
isResumed = true; | ||
}); | ||
return processPromise; | ||
@@ -518,4 +533,3 @@ }); | ||
await queue.process(async () => { }); | ||
await queue.add('test', {}); | ||
return new Promise((resolve, reject) => { | ||
const promise = new Promise((resolve, reject) => { | ||
queue.on('global:drained', async () => { | ||
@@ -534,2 +548,5 @@ try { | ||
}); | ||
await queue.queueEvents.waitUntilReady(); | ||
await queue.add('test', {}); | ||
return promise; | ||
}); | ||
@@ -536,0 +553,0 @@ }); |
{ | ||
"name": "bullmq", | ||
"version": "1.6.1", | ||
"version": "1.6.2", | ||
"description": "Queue for messages and jobs based on Redis", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -45,7 +45,6 @@ // Type definitions for bull 3.10 | ||
name: string; | ||
queueEvents: QueueEvents; | ||
private opts: CommonOptions; | ||
private readonly queue: Queue; | ||
private queueEvents: QueueEvents; | ||
private worker: Worker; | ||
@@ -52,0 +51,0 @@ private queueScheduler: QueueScheduler; |
@@ -28,3 +28,3 @@ import { QueueEventsOptions } from '../interfaces'; | ||
const key = this.keys.events; | ||
let id = opts.lastEventId || '0-0'; | ||
let id = opts.lastEventId || '$'; | ||
@@ -31,0 +31,0 @@ while (!this.closing) { |
@@ -372,19 +372,33 @@ /*eslint-env node */ | ||
it('should listen to global events', function(done) { | ||
let state: string; | ||
queue.on('global:waiting', function() { | ||
expect(state).to.be.undefined; | ||
state = 'waiting'; | ||
}); | ||
queue.once('global:active', function() { | ||
expect(state).to.be.equal('waiting'); | ||
state = 'active'; | ||
}); | ||
queue.once('global:completed', async function() { | ||
expect(state).to.be.equal('active'); | ||
done(); | ||
}); | ||
it('should listen to global events with .once', async function() { | ||
const events: string[] = []; | ||
queue.once('global:waiting', () => events.push('waiting')); | ||
queue.once('global:active', () => events.push('active')); | ||
queue.once('global:completed', () => events.push('completed')); | ||
await queue.queueEvents.waitUntilReady(); | ||
await queue.add('test', {}); | ||
await queue.add('test', {}); | ||
await queue.process(() => null); | ||
await delay(50); | ||
expect(events).to.eql(['waiting', 'active', 'completed']); | ||
}); | ||
queue.add('test', {}); | ||
queue.process(async () => {}); | ||
it('should listen to global events with .on', async function() { | ||
const events: string[] = []; | ||
queue.on('global:waiting', () => events.push('waiting')); | ||
queue.on('global:active', () => events.push('active')); | ||
queue.on('global:completed', () => events.push('completed')); | ||
await queue.queueEvents.waitUntilReady(); | ||
await queue.add('test', {}); | ||
await queue.add('test', {}); | ||
await queue.process(() => null); | ||
await delay(50); | ||
expect(events).to.eql([ | ||
'waiting', | ||
'waiting', | ||
'active', | ||
'completed', | ||
'active', | ||
'completed', | ||
]); | ||
}); | ||
@@ -447,2 +461,13 @@ }); | ||
queue.on('global:paused', async () => { | ||
isPaused = false; | ||
await queue.resume(); | ||
}); | ||
queue.on('global:resumed', () => { | ||
isResumed = true; | ||
}); | ||
await queue.queueEvents.waitUntilReady(); | ||
const processPromise = new Promise((resolve, reject) => { | ||
@@ -473,11 +498,2 @@ process = async (job: Job) => { | ||
queue.on('global:paused', async () => { | ||
isPaused = false; | ||
await queue.resume(); | ||
}); | ||
queue.on('global:resumed', () => { | ||
isResumed = true; | ||
}); | ||
return processPromise; | ||
@@ -625,5 +641,3 @@ }); | ||
await queue.add('test', {}); | ||
return new Promise((resolve, reject) => { | ||
const promise = new Promise((resolve, reject) => { | ||
queue.on('global:drained', async () => { | ||
@@ -642,4 +656,9 @@ try { | ||
}); | ||
await queue.queueEvents.waitUntilReady(); | ||
await queue.add('test', {}); | ||
return promise; | ||
}); | ||
}); | ||
}); |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1001629
17148