-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix(queue): enabled queues to share childPool instance #2237
Conversation
@jfontaine-lifion This is awesome. Might save memory. Provided, not all queues process simultaneously. |
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.
Thanks. This could be useful for other users. Please check my comments.
lib/scripts.js
Outdated
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 comment
The 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
test/test_queue.js
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
We should use single quotes instead of double.
test/test_queue.js
Outdated
@@ -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 comment
The 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.
test/test_queue.js
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Use single quotes
lib/queue.js
Outdated
@@ -215,7 +216,8 @@ const Queue = function Queue(name, url, opts) { | |||
guardInterval: 5000, | |||
retryProcessDelay: 5000, | |||
drainDelay: 5, | |||
backoffStrategies: {} | |||
backoffStrategies: {}, | |||
isSharedChildPool: false |
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
@manast I applied the feedback and added some unit tests |
# [4.2.0](v4.1.4...v4.2.0) (2021-12-21) ### Features * **queue:** enabled queues to share childPool instance ([#2237](#2237)) ([16fdbe9](16fdbe9))
🎉 This PR is included in version 4.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
My team use bull queues to create dynamic queues and noticed that we for every instance of a queue a childPool instance is create. This change allows multiple bull queues to share the same bull queue instance.