brandonhilkert / sucker_punch

Sucker Punch is a Ruby asynchronous processing library using concurrent-ruby, heavily influenced by Sidekiq and girl_friday.
MIT License
2.64k stars 114 forks source link

Is async needed when scheduling a job? #45

Closed snovity closed 10 years ago

snovity commented 10 years ago

Grate gem, thanks for your work! A few questions about documentation. Here is a quote from it.

Job.new.async.later(60, "asdf") # `perform` will be excuted 60 sec. later
Job.new.async.after(60){ perform("asdf") } # Same as previous, doesn't require extra instance method

But it seems everything is working just fine when doing just Job.new.later(60, "asdf"). As I understand it, the only thing that async does in this case, is that timer setup itself is happening asynchronously. Is it correct? (I'm new to Celluloid)

Also, it seems that a call without dedicated method Job.new.async.after(60){ perform("asdf") } can't work without instantiating Job inside block again. And maybe shouldn't be advised to use at all, because at least I experienced that in case of an exception happening directly inside block (without crossing the Agent boundary), instead of a worker the PoolManager itself crashes and no jobs are ever done without process restart.

brandonhilkert commented 10 years ago

async isn't totally needed. If you wanted manage the timer in some way, then don't use async. However, I imagined it more of a "set it and forget it" operation just putting it in to a new thread using async is ok too.

I'm not sure I follow the last part. Showing me some code might help.

brandonhilkert commented 10 years ago

oh...I see what you're saying about Job.new.async.after(60){ perform("asdf") }. I've removed it from the README.