node-resque icon indicating copy to clipboard operation
node-resque copied to clipboard

Why does jobs need to be passed to queue?

Open fo-fo opened this issue 4 years ago • 6 comments

The documentation has the following blurb:

new queue requires only the "queue" variable to be set. You can also pass the jobs hash to it.

What happens if I don't pass jobs? Why would I pass it if it's optional?

I was looking at the code (queue.ts), and it looked like the job's plugins would not run if I don't pass jobs to the queue (as const job = this.jobs[func]; would be undefined), is this intentional?

fo-fo avatar Oct 31 '21 08:10 fo-fo

It's the other way around I think - if you don't pass jobs, queue.enqueue(), RunPlugins() would always succeed because the job couldn't be found.

I'll update the docs to to say:

new queue requires only the "queue" variable to be set. If you intent to run plugins before or after enquing a job, you should also pass the jobs hash to it.

evantahler avatar Oct 31 '21 19:10 evantahler

It's the other way around I think - if you don't pass jobs, queue.enqueue(), RunPlugins() would always succeed because the job couldn't be found.

That's what I meant – the plugins set for the job would never run unless jobs is passed to the queue. Changing the docs sounds like a good idea, although in my mind it almost sounds like it should be a mandatory parameter, because the behavior without it is quite surprising in my opinion.

fo-fo avatar Nov 02 '21 16:11 fo-fo

Ah, understood! Please send in a PR with your suggested change, and we can discuss it there!

evantahler avatar Nov 02 '21 17:11 evantahler

Ping! checking in @fo-fo - do you need any help with that PR?

evantahler avatar Nov 20 '21 22:11 evantahler

Ping! checking in @fo-fo - do you need any help with that PR?

Hey, sorry, I haven't had time to do it (yet at least). Actually it's not a big deal to me whether the documentation gets changed, although I appreciate you verifying my assumption about how it works!

fo-fo avatar Nov 25 '21 13:11 fo-fo

I'd be very happy with the update if you could make it!

evantahler avatar Nov 26 '21 18:11 evantahler