ti2 1.0.125 → 1.0.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/worker/__tests__/queue-remove.js +12 -0
- package/worker/queue.js +6 -1
package/package.json
CHANGED
|
@@ -14,6 +14,7 @@ jest.mock('bull', () => jest.fn(() => mockQueue));
|
|
|
14
14
|
jest.mock('ioredis', () => jest.fn(() => mockRedis));
|
|
15
15
|
|
|
16
16
|
jest.resetModules();
|
|
17
|
+
const Queue = require('bull');
|
|
17
18
|
const { removeJob } = require('../queue');
|
|
18
19
|
|
|
19
20
|
const occurrenceId = ({
|
|
@@ -26,6 +27,17 @@ const occurrenceId = ({
|
|
|
26
27
|
return `repeat:${repeatHash}:${timestamp}`;
|
|
27
28
|
};
|
|
28
29
|
|
|
30
|
+
describe('queue settings', () => {
|
|
31
|
+
it('keeps long-running jobs locked while the worker is active', () => {
|
|
32
|
+
expect(Queue).toHaveBeenCalledWith('work', expect.any(String), {
|
|
33
|
+
settings: {
|
|
34
|
+
lockDuration: 120e3,
|
|
35
|
+
lockRenewTime: 15e3,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
29
41
|
describe('removeJob', () => {
|
|
30
42
|
beforeEach(() => {
|
|
31
43
|
jest.clearAllMocks();
|
package/worker/queue.js
CHANGED
|
@@ -6,7 +6,12 @@ const Redis = require('ioredis');
|
|
|
6
6
|
const REDIS_URL = process.env.REDIS_URL || 'redis://redis:6379';
|
|
7
7
|
const itemsTTL = 3 * 60 * 60; // 3 hours
|
|
8
8
|
|
|
9
|
-
const queue = new Queue('work', `${REDIS_URL}/0
|
|
9
|
+
const queue = new Queue('work', `${REDIS_URL}/0`, {
|
|
10
|
+
settings: {
|
|
11
|
+
lockDuration: 120e3,
|
|
12
|
+
lockRenewTime: 15e3,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
10
15
|
const redisResults = new Redis(`${REDIS_URL}/1`);
|
|
11
16
|
|
|
12
17
|
const getPending = async () => {
|