Commit b19a8bf4 authored by Manuel Astudillo's avatar Manuel Astudillo
Browse files

Merge branch 'master' of github.com:OptimalBits/bull

parents d87ffc64 1b6b08d5
develop BRPOPLPUSH add-after-remove-repeatable avoid-repeatable-jobs-duplication-every-1003 better-check-closing-stalled-jobs better-disconnect-and-process-args-handling better-is-ready-handling check-closing-queue-in-is-finished dependabot/npm_and_yarn/minimist-1.2.8 dependabot/npm_and_yarn/qs-6.5.3 do-not-close-external-connections emit-waiting-delayed events-counter extra-test-870 feat/add-isPaused feat/add-obliterate-method fetch-next-job-on-completed fix-delay fix-issue-812 fix-progress-event fix/958-finished-slowdown fix/better-delay-jobs-handling fix/better-rate-limiting fix/fix-typescript-processors fix/noscript fix/obliterate-many-jobs fix/properly-remove-sandbox-events fix/safer-obliterate fix/upgrade-lodash-to-avoid-vulnerability fixed-repeatable-job-remove github/fork/ASWATFZLLC/buffer github/fork/HugoPoi/develop github/fork/Thore1954/fix-repeat-limit-reset github/fork/dawiss1337/master github/fork/mamousavi/fix/add-missing-keys-to-repeat-opts github/fork/rysi3k/taking_lock_with_force global-stalled master multiple-cron native-promises next rate-limiter threaded-process throw-error-if-invalid-processor-file update-job-data winds_sponsoring v4.10.4 v4.10.3 v4.10.2 v4.10.1 v4.10.0 v4.9.0 v4.8.5 v4.8.4 v4.8.3 v4.8.2 v4.8.1 v4.8.0 v4.7.0 v4.6.2 v4.6.1 v4.6.0 v4.5.6 v4.5.5 v4.5.4 v4.5.3 v4.5.2 v4.5.1 v4.5.0 v4.4.0 v4.3.0 v4.2.1 v4.2.0 v4.1.4 v4.1.3 v4.1.2 v4.1.1 v4.1.0 v4.0.0 v3.29.3 v3.29.2 v3.29.1 v3.29.0 v3.28.1 v3.28.0 v3.27.0 v3.26.0 v3.25.2 v3.25.1 v3.25.0 v3.24.0 v3.23.3 v3.23.2 v3.23.1 v3.23.0 v3.22.12 v3.22.11 v3.22.10 v3.22.9 v3.22.8 v3.22.7 v3.22.6 v3.22.5 v3.22.4 v3.22.3 v3.22.2 v3.22.1 v3.22.0 v3.21.1 v3.21.0 v3.20.1 v3.20.0 v3.19.1 v3.19.0 v3.18.1 v3.18.0 v3.17.0 v3.16.0 v3.15.0 v3.14.0 v3.13.0 v3.12.1 v3.12.0 v3.11.0 v3.10.0 v3.9.0 v3.8.1 v3.8.0 v3.7.0 v3.6.0 v3.5.3 v3.5.2 v3.5.1 v3.5.0 v3.4.8 v3.4.7 v3.4.6 v3.4.5 v3.4.4 v3.4.3 v3.4.2 v3.4.1 v3.4.0 v3.3.10 v3.3.9 v3.3.8 v3.3.7 v3.3.6 v3.3.5 v3.3.4 v3.3.3 v3.3.2 v3.3.1 v3.3.0 v3.2.0 v3.1.0 v3.0.0 v3.0.0-rc.10 v3.0.0-rc.9 v3.0.0-rc.8 v3.0.0-rc7 v.3.0.0-rc.6
No related merge requests found
Showing with 48 additions and 43 deletions
+48 -43
......@@ -33,6 +33,9 @@
<a href="http://badge.fury.io/js/bull">
<img src="https://badge.fury.io/js/bull.svg"/>
</a>
<a href="https://coveralls.io/github/OptimalBits/bull?branch=master">
<img src="https://coveralls.io/repos/github/OptimalBits/bull/badge.svg?branch=master"/>
</a>
<a href="http://isitmaintained.com/project/OptimalBits/bull">
<img src="http://isitmaintained.com/badge/open/optimalbits/bull.svg"/>
</a>
......
......@@ -37,8 +37,7 @@ module.exports = (function (){
function loadScripts(dir) {
return fs.readdirAsync(dir).filter(function (file){
return path.extname(file) === '.lua';
})
.map(function (file) {
}).map(function (file) {
var longName = path.basename(file, '.lua');
var name = longName.split('-')[0];
var numberOfKeys = parseInt(longName.split('-')[1]);
......@@ -50,4 +49,4 @@ function loadScripts(dir) {
};
});
});
}
\ No newline at end of file
}
......@@ -239,11 +239,12 @@ Job.prototype.promote = function(){
keys.length,
keys[0],
keys[1],
jobId).then(function(result){
if(result === -1){
throw new Error('Job ' + jobId + ' is not in a delayed state');
}
});
jobId
).then(function(result){
if(result === -1){
throw new Error('Job ' + jobId + ' is not in a delayed state');
}
});
};
/**
......
......@@ -209,8 +209,8 @@ var Queue = function Queue(name, url, opts){
function redisClientGetter(queue, options, initCallback) {
var createClient = _.isFunction(options.createClient)
? options.createClient
: function(type, config) { return new redis(config); };
? options.createClient
: function(type, config) { return new redis(config); };
var connections = {};
......
......@@ -61,21 +61,22 @@ module.exports = function(Queue){
end = end || -1;
return (asc ?
this.client.zrange(key, start, end, 'WITHSCORES') :
this.client.zrevrange(key, start, end, 'WITHSCORES')).then(function(result){
var jobs = [];
for(var i=0; i<result.length; i+=2){
var data = result[i].split(':');
jobs.push({
name: data[0],
id: data[1] || null,
endDate: parseInt(data[2]) || null,
tz: data[3] || null,
cron: data[4],
next: parseInt(result[i+1])
});
}
return jobs;
});
this.client.zrevrange(key, start, end, 'WITHSCORES')
).then(function(result){
var jobs = [];
for(var i=0; i<result.length; i+=2){
var data = result[i].split(':');
jobs.push({
name: data[0],
id: data[1] || null,
endDate: parseInt(data[2]) || null,
tz: data[3] || null,
cron: data[4],
next: parseInt(result[i+1])
});
}
return jobs;
});
};
Queue.prototype.getRepeatableCount = function(){
......
......@@ -22,7 +22,7 @@ queue.process(1, function(job, jobDone) {
process.on('disconnect', function () {
queue.close().then(function () {
// process.exit(0);
// process.exit(0);
}).catch(function (err) {
console.error(err);
// process.exit(-1);
......
......@@ -1528,24 +1528,25 @@ describe('Queue', function () {
queue.add({ order: 2 }, { delay: 300 }),
queue.add({ order: 4 }, { delay: 500 }),
queue.add({ order: 1 }, { delay: 200 }),
queue.add({ order: 3 }, { delay: 400 })).then(function () {
//
// Start processing so that jobs get into the delay set.
//
queue.process(fn);
}).delay(20).then(function () {
/*
//We simulate a restart
console.log('RESTART');
return queue.close().then(function () {
console.log('CLOSED');
return Promise.delay(100).then(function () {
queue = new Queue(QUEUE_NAME);
queue.process(fn);
});
queue.add({ order: 3 }, { delay: 400 })
).then(function () {
//
// Start processing so that jobs get into the delay set.
//
queue.process(fn);
}).delay(20).then(function () {
/*
//We simulate a restart
console.log('RESTART');
return queue.close().then(function () {
console.log('CLOSED');
return Promise.delay(100).then(function () {
queue = new Queue(QUEUE_NAME);
queue.process(fn);
});
*/
});
*/
});
});
it('should process delayed jobs with exact same timestamps in correct order (FIFO)', function (done) {
......@@ -2458,4 +2459,4 @@ describe('Queue', function () {
});
});
});
});
\ No newline at end of file
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment