New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(queue): enabled queues to share childPool instance #2237
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -326,17 +326,13 @@ const scripts = { | |
return allRemoved; | ||
}, | ||
|
||
extendLock( | ||
queue, | ||
jobId, | ||
duration, | ||
) { | ||
extendLock(queue, jobId, duration) { | ||
return queue.client.extendLock([ | ||
queue.toKey(jobId) + ':lock', | ||
queue.keys.stalled, | ||
queue.token, | ||
duration, | ||
jobId, | ||
jobId | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not following the current format standard, we use trailing commas (as the default in "prettier"): https://stackoverflow.com/questions/61370583/trailing-comma-after-last-line-in-object |
||
]); | ||
}, | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -405,7 +405,7 @@ describe('Queue', () => { | |
}); | ||
}); | ||
|
||
describe(' a worker', () => { | ||
describe('a worker', () => { | ||
let queue; | ||
|
||
beforeEach(() => { | ||
|
@@ -2121,6 +2121,17 @@ describe('Queue', () => { | |
queue.on('failed', cb); | ||
queue.on('error', done); | ||
}); | ||
|
||
it('should share child pool across all different queues created', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great to also test the opposite behavior, i.e. that the pools are different if we are not specifying the isSharedChildPool. |
||
const [queueA, queueB] = await Promise.all([ | ||
utils.newQueue('queueA', { settings: { isSharedChildPool: true } }), | ||
utils.newQueue('queueB', { settings: { isSharedChildPool: true } }) | ||
]); | ||
|
||
await Promise.all([queueA.add(), queueB.add()]); | ||
|
||
expect(queueA.childPool).to.be.eql(queueB.childPool); | ||
}); | ||
}); | ||
|
||
describe('Retries and backoffs', () => { | ||
|
@@ -2837,11 +2848,14 @@ describe('Queue', () => { | |
}); | ||
}); | ||
|
||
it('should clean the number of jobs requested even if first jobs timestamp doesn\'t match', async () => { | ||
it("should clean the number of jobs requested even if first jobs timestamp doesn't match", async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should use single quotes instead of double. |
||
// This job shouldn't get deleted due to the 5000 grace | ||
await queue.add({ some: 'data' }); | ||
// This job should get cleaned since 10000 > 5000 grace | ||
const jobToClean = await queue.add({ some: 'data' }, { timestamp: Date.now() - 10000 }); | ||
const jobToClean = await queue.add( | ||
{ some: 'data' }, | ||
{ timestamp: Date.now() - 10000 } | ||
); | ||
// This job shouldn't get deleted due to the 5000 grace | ||
await queue.add({ some: 'data' }); | ||
|
||
|
@@ -2853,7 +2867,7 @@ describe('Queue', () => { | |
expect(len).to.be.eql(2); | ||
}); | ||
|
||
it('shouldn\'t clean anything if all jobs are in grace period', async () => { | ||
it("shouldn't clean anything if all jobs are in grace period", async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use single quotes |
||
await queue.add({ some: 'data' }); | ||
await queue.add({ some: 'data' }); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use trailing commas