lykmapipo / kue-scheduler

A job scheduler utility for kue, backed by redis and built for node.js
246 stars 47 forks source link

Non-worker queues still process jobs. #89

Open schmod opened 7 years ago

schmod commented 7 years ago

The behavior of kue.createQueue({ worker: false }) is inconsistent with the documentation.

Currently, this flag only controls whether or not the queue will process jobs created with .every(). Queues created as "non-workers" will still process jobs in all other circumstances.

In the following example, the job gets processed, even though the queue has been marked as a "non-worker".

var Queue = kue.createQueue({ worker: false });

var job = Queue
    .createJob('myJob', data)
    .attempts(3)
    .backoff(backoff)
    .priority('normal');

Queue.schedule('3 seconds from now', job);

Queue.process('myJob', function (job, finalize) {
  console.log('Hello World!');
  finalize();
});
lykmapipo commented 7 years ago

@schmod I will appreciate a PR with the fix.

schmod commented 7 years ago

What do you think the appropriate behavior should be? Should Queue.process() throw an error if we try to call it on a non-worker, or should it simply not do anything?

samhunta commented 7 years ago

My current setup contains micro services which I don't include the processing code for non workers. There's no good reason to have non-workers include that extra code anyway.