actionhero / node-resque

Node.js Background jobs backed by redis.
https://node-resque.actionherojs.com
Apache License 2.0
1.37k stars 151 forks source link

Queue API usability #414

Closed glensc closed 4 years ago

glensc commented 4 years ago

Seems the queue api only returns boolean, no way to get any job id out of it, like for future polling of the job.

There isn't even any events on queue object (other than "error"), like could capture the job id via "job":

    worker.on("job", async (queue: string, job: Job<any> | JobEmit) => {
      await this.onJob(job);
    });

code

  const queue = new Queue({ connection: connectionDetails }, jobs);
  queue.on("error", function (error) {
    console.log('queue error:', error);
  });
  await queue.connect();
  const result = await queue.enqueue("math", "add", [1, 2]);
  console.log(result);
glensc commented 4 years ago

so far I've used php-resque to create jobs, and seems there the id and prefix is created by client when creating new job:

and node side encode:

seems the 'queue' being encoded as value is superfluous as well in node side.

evantahler commented 4 years ago

There are no job-ids in Ruby's or Node-resuqe. That's a concept that the PHP fork introduced.

As we discussed in https://github.com/actionhero/node-resque/issues/334#issuecomment-638585235, I think adding Job IDs would be great addition to the package... but we don't have them yet.

glensc commented 4 years ago

@evantahler do you agree the queue in value is superfluous in node-resque? or it's used internally somewhere therefore needed?

evantahler commented 4 years ago

I don't think so... if the job is delayed, the queue param needs to be kept around to know the eventual work queue to move it into. Also, if the job fails, it will be useful to know which queue the failure was from... as perhaps you have different workers/apps working each queue.