The way I understand how Kue works, I need to specify the type of job I'm going to get:
jobs.process('email', function(job, done){
var pending = 5
, total = pending;
setInterval(function(){
job.log('sending!');
job.progress(total - pending, total);
--pending || done();
}, 1000);
});
where 'email' is the job type. What I'm trying to do is get the next job in the queue regardless of type. Is that doable?
For reference, my object has methods that are named the same thing that the job is so it wont matter what kind of job I pull out, I can always handle it with my job worker.
What I ultimately did was make several broad classes of tasks, and insert the name of the worker to all as part of the job. The code ended up looking like this:
jobs.process('social_post', function(job, done){
var this_worker = factory(job.data.worker);
this_worker(job,done);
});
The factory is pretty simple:
var worker_factory = function(worker_name) {
switch(worker_name){
case 'facebook':
return FacebookWorker;
case 'social_response':
return SocialResponder;
};
};
I'm using the responder queue as overkill for Kue's already full featured task management.
Hope this helps.