technoweenie / coffee-resque

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Passing arguments without array breaks it

StevePotter opened this issue · comments

resque.enqueue('x', 'y', { foo: 0 })

Sends fine but the worker breaks. This is due to to Worker.prototype.perform using __slice.call on the arguments, which creates an empty array. The result is no argument passed to the worker function and the "args" is actually the callback.

It would be better to check for an array vs object and maybe not use __slice.call. You want me to do it?

It's documented in the api that the args are passed as an array. However, I think this can be avoided by using a splat for enqueue like so.

 enqueue: (queue, func, args...) ->

This change would not be backwards compatible. So for now did you try this?

resque.enqueue('x', 'y', [{ foo: 0 }])

hey bro, I realize the docs were right but I sorta just expected it to work. I mostly just used your example and changed things around. Wrapping it in an array did work so no problem there. Just a suggestion. If I can lend a hand, let me know

On Sep 21, 2012, at 7:12 PM, Sean McDaniel notifications@github.com wrote:

It's documented in the api that the args are passed as an array. However, I think this can be avoided by using a splat for enqueue like so.

enqueue: (queue, func, args...) ->
This change would not be backwards compatible. So for now did you try this?

resque.enqueue('x', 'y', [{ foo: 0 }])

Reply to this email directly or view it on GitHub.

I like the suggestion since the usage of an array for job args is really an implementation detail of resque. Ruby resque encodes jobs in the same way which allows for interoperability between node and ruby. This provides some flexibility that I have taken advantage of personally.

In any case, like I mentioned before it would seem that using a CS splat would be all that is necessary to allow users to pass a variable # of args. It's not a lot of work but I don't really have the time to do it this week.