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

Do not overwrite .new / leave simple perform alone #120

Closed grosser closed 9 years ago

grosser commented 9 years ago

I felt it hard to test my jobs since .perform/.new are already overwritten, would it make sense that .new and .perform behave normally and just .async triggers celluloid magic ?

@brandonhilkert

FYI doing this to keep my job testable:

class BackgroundJobTestable
  def perform
    ...
end

class BackgroundJob < BackgroundJobTestable
  include SuckerPunch::Job
  workers 2
end
brandonhilkert commented 9 years ago

Celluloid is overriding those methods. Unless Celluloid is completely abandoned, I don't see a clear way to avoid this. What issues are you having with testing?

grosser commented 9 years ago

I was hoping to not include Celluloids and just make def async; Celluloid.async(self);end or something like that, basically keeping the class 'plain' ... but that would break a bunch of stuff ... so just keeping my inheritance workaround ...