Last active
August 29, 2015 14:27
-
-
Save firedfox/ad303fe23392f851707d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var PriorityQueue = require('bull/lib/priority-queue'); | |
var queue = new PriorityQueue('jobQueue', 6379, '127.0.0.1'); | |
var MAX = 10000; | |
var n = 0; | |
var addToQueue = function() { | |
queue.add( | |
{ url: 'http://tongji.baidu.com/?n=' + n, key: 'f4fa3fee9ab83b9d06db835828450ff1', extData: { x: 0 }, reporter: { ip: '1.2.3.4' } }, { priority: "normal" } | |
//{ url: 'http://127.0.0.1:7888/?n=' + n, key: 'f4fa3fee9ab83b9d06db835828450ff1', extData: { x: 0 }, reporter: { ip: '1.2.3.4' } }, { priority: "normal" } | |
).then(function() { | |
if (++n < MAX) { addToQueue(); } | |
else { process.exit(); } | |
}); | |
}; | |
queue.empty().then(addToQueue); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var PriorityQueue = require('bull/lib/priority-queue'); | |
var queue = new PriorityQueue(jobQueue', 6379, '127.0.0.1'); | |
queue.process(function(job, done){ | |
console.log(job.jobId, JSON.stringify(job.data)); | |
done(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Queue = require('bull'); | |
var queue = new Queue('resultQueue', 6379, '127.0.0.1'); | |
queue.process(function(msg, done){ | |
console.log(job.jobId, JSON.stringify(job.data)); | |
done(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment