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

How to get the return value for an async job #161

Closed jlecour closed 8 years ago

jlecour commented 8 years ago

Hi Brandon,

I was very pleased to see that you've migrated SuckerPunch to concurrent-ruby. As I was trying to upgrade, I've had some issues.

In order to fetch the return value from async job, I've been using future as in

future = MyJob.new.future.perform()
# …
expected = future.value

future in a celluloid API, which is now missing. Is there a good way to achieve a similar result with SuckerPunch 2.0 ?

Thanks again for maintaining this great piece of software.

jlecour commented 8 years ago

It seems that concurrent-ruby provides a Concurrent::Future.execute block that I could use for this. I'll go and try this.

On a more general level, is this a feature that you've considered adding to SuckerPunch ? From my point of view it makes sense and stays in SuckerPunch's mission, with a coherent API.

brandonhilkert commented 8 years ago

hey @jlecour - Checking out Concurrent::Future.execute makes sense. The fact that you could use future was an implementation detail of the old API that i didn't do well. Exposing all of Celluloid was a mistake in my mind. You're the first person I've heard of asking for futures. Not that that's a bad thing, but I suppose if the demand was there, I'd consider it. Not sure I could do much better than what Concurrent::Future.execute supplies already.