Skip to content
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: pass redis string as opts into queue #2664

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ const Queue = function Queue(name, url, opts) {

opts.redis = {
enableReadyCheck: false,
...opts.redis
...(_.isString(opts.redis)
? { ...redisOptsFromUrl(opts.redis) }
: opts.redis)
};

_.defaults(opts.redis, {
Expand Down Expand Up @@ -913,7 +915,7 @@ Queue.prototype.isPaused = async function(isLocal) {
};

Queue.prototype.run = function(concurrency, handlerName) {
if(!Number.isInteger(concurrency)) {
if (!Number.isInteger(concurrency)) {
throw new Error('Cannot set Float as concurrency');
}
const promises = [];
Expand Down
12 changes: 6 additions & 6 deletions test/test_child-pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ describe('Child pool', () => {
});

it('should not overwrite the the childPool singleton when isSharedChildPool is false', () => {
const childPoolA = new childPool(true)
const childPoolB = new childPool(false)
const childPoolA = new childPool(true);
const childPoolB = new childPool(false);
const childPoolC = new childPool(true);

expect(childPoolA).to.be.equal(childPoolC)
expect(childPoolB).to.not.be.equal(childPoolA)
expect(childPoolB).to.not.be.equal(childPoolC)
})
expect(childPoolA).to.be.equal(childPoolC);
expect(childPoolB).to.not.be.equal(childPoolA);
expect(childPoolB).to.not.be.equal(childPoolC);
});
});
17 changes: 17 additions & 0 deletions test/test_queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,23 @@ describe('Queue', () => {
return queue.close();
});

it('creates a queue using the supplied redis url as opts', () => {
const queue = new Queue('custom', {
redis: 'redis://abc:[email protected]:1234/1'
});

expect(queue.client.options.host).to.be.eql('127.2.3.4');
expect(queue.eclient.options.host).to.be.eql('127.2.3.4');

expect(queue.client.options.port).to.be.eql(1234);
expect(queue.eclient.options.port).to.be.eql(1234);

expect(queue.client.options.db).to.be.eql(1);
expect(queue.eclient.options.db).to.be.eql(1);

return queue.close();
});

it('creates a queue using the supplied redis host', () => {
const queue = new Queue('custom', { redis: { host: 'localhost' } });

Expand Down
Loading