brandonhilkert / sucker_punch

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

Callback / Notification when Job is complete #167

Closed b0rgbart3 closed 8 years ago

b0rgbart3 commented 8 years ago

Hi Brandon - This is more of a Question rather than an Issue. Is there a way to setup a callback or a method that gets called when all of the jobs are done? I'm using SuckerPunch to upload images in the background and it works great - but it would be great if SuckerPunch could tell my app when it's finished.... (so I can refresh the page and/or notify the user). I'm fairly new to Rails so maybe there's an obvious way to do this.... Thanks!

brandonhilkert commented 8 years ago

hey @b0rgbart3 - There is nothing like that now. Are you looking for when each job is finished?

b0rgbart3 commented 8 years ago

Actually I was just looking to get notified when the whole batch is done. Since I'm using it to upload images, it takes quite a while and depends on how many images the user uploads. I thought about just setting up a javascript refresh - but that doesn't seem very Rails-like or very elegant. :-)

brandonhilkert commented 8 years ago

There is no notion of a batch notification. @mperham's Sidekiq pro and above has that capability.

You could write your own by starting a counter somewhere with the total number of image jobs to process and then once each job completes, decrement the counter and then have a final job that checks the counter until it's 0 and performs whatever notification code you want.

Any else I can think of would be written manually without any help from Sucker Punch internals.

b0rgbart3 commented 8 years ago

Thanks Brandon!