Skip to content

Instantly share code, notes, and snippets.

@firedfox
Last active August 29, 2015 14:27
Show Gist options
  • Save firedfox/ad303fe23392f851707d to your computer and use it in GitHub Desktop.
Save firedfox/ad303fe23392f851707d to your computer and use it in GitHub Desktop.
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);
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();
});
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