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

No Way to Set Workers When Used Via ActiveJob #189

Closed thedillonb closed 7 years ago

thedillonb commented 7 years ago

Setting workers is done via the Job instance. However, via ActiveJob, that interface is abstracted from us. There's no way to then set the workers for that particular job.

brandonhilkert commented 7 years ago

Yeah, I hear you. I don't use ActiveJob, so it hasn't been a huge deal for me, but open to PR's if that's something that's even possible (I don't know if it is).

grosser commented 7 years ago

active_job implementation is here: https://github.com/rails/rails/blob/master/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb

so could do:

# config/initializers/sucker_punch.rb
ActiveJob::QueueAdapters::SuckerPunchAdapter::JobWrapper.workers 1

to force single-file execution of all jobs ...

# test it out:
class Foobar < ActiveJob::Base
  def perform
    puts 'start'
    sleep 5
    puts 'done'
  end
end

5.times { Foobar.perform_later }
phlegx commented 7 years ago

Is there a way to set SuckerPunch workers globally?

brandonhilkert commented 7 years ago

@phlegx Not currently