Automattic / kue

Kue is a priority job queue backed by redis, built for node.js.
http://automattic.github.io/kue
MIT License
9.45k stars 862 forks source link

queue.process variables #1129

Closed lucasreppewelander closed 6 years ago

lucasreppewelander commented 6 years ago

Hello, on the queue.process() can I get the first parameter as a variable? I'm having like 6 different jobs, and would love to be able to write just one queue process just to keep my code down, as right now there are 6 exact equal functions just calling other functions with strings instead of variables.

I was thinking something like

queue.process(type, 1, (job, done) => {
    jobs[type](job.data).then(result) => {
        done();
    }
});
behrad commented 6 years ago

I think you can use job.type if not mistaken!