diff options
-rw-r--r-- | Gemfile | 3 | ||||
-rw-r--r-- | Gemfile.lock | 10 | ||||
-rw-r--r-- | activejob/lib/active_job/queue_adapters.rb | 2 | ||||
-rw-r--r-- | activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb | 15 |
4 files changed, 21 insertions, 9 deletions
@@ -48,7 +48,7 @@ group :job do gem 'resque', require: false gem 'resque-scheduler', require: false gem 'sidekiq', require: false - gem 'sucker_punch', '< 2.0', require: false + gem 'sucker_punch', require: false gem 'delayed_job', require: false gem 'queue_classic', github: "QueueClassic/queue_classic", branch: 'master', require: false, platforms: :ruby gem 'sneakers', require: false @@ -58,6 +58,7 @@ group :job do gem 'qu-redis', require: false gem 'delayed_job_active_record', require: false gem 'sequel', require: false + gem 'celluloid', require: false end # Action Cable diff --git a/Gemfile.lock b/Gemfile.lock index a7b1daaef4..52add9070a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -105,7 +105,7 @@ GEM bunny (2.2.1) amq-protocol (>= 2.0.0) byebug (8.2.1) - celluloid (0.17.2) + celluloid (0.17.3) celluloid-essentials celluloid-extras celluloid-fsm @@ -151,7 +151,6 @@ GEM activesupport (>= 4.1.0) hiredis (0.5.2) hitimes (1.2.3) - hitimes (1.2.3-x86-mingw32) i18n (0.7.0) jquery-rails (4.0.5) rails-dom-testing (~> 1.0) @@ -260,8 +259,8 @@ GEM sqlite3 (1.3.11-x64-mingw32) sqlite3 (1.3.11-x86-mingw32) stackprof (0.2.7) - sucker_punch (1.6.0) - celluloid (~> 0.17.2) + sucker_punch (2.0.0) + concurrent-ruby (~> 1.0.0) thor (0.19.1) thread (0.1.7) thread_safe (0.3.5) @@ -299,6 +298,7 @@ DEPENDENCIES bcrypt-ruby (~> 3.0.0) benchmark-ips byebug + celluloid coffee-rails (~> 4.1.0) dalli (>= 2.2.1) delayed_job @@ -334,7 +334,7 @@ DEPENDENCIES sneakers sqlite3 (~> 1.3.6) stackprof - sucker_punch (< 2.0) + sucker_punch turbolinks tzinfo-data uglifier (>= 1.3.0) diff --git a/activejob/lib/active_job/queue_adapters.rb b/activejob/lib/active_job/queue_adapters.rb index aeb1fe1e73..2c5039ef4d 100644 --- a/activejob/lib/active_job/queue_adapters.rb +++ b/activejob/lib/active_job/queue_adapters.rb @@ -27,7 +27,7 @@ module ActiveJob # | Resque | Yes | Yes | Yes (Gem) | Queue | Global | Yes | # | Sidekiq | Yes | Yes | Yes | Queue | No | Job | # | Sneakers | Yes | Yes | No | Queue | Queue | No | - # | Sucker Punch | Yes | Yes | No | No | No | No | + # | Sucker Punch | Yes | Yes | Yes | No | No | No | # | Active Job Async | Yes | Yes | Yes | No | No | No | # | Active Job Inline | No | Yes | N/A | N/A | N/A | N/A | # diff --git a/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb b/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb index c6c35f8ab4..1037084341 100644 --- a/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb @@ -19,11 +19,22 @@ module ActiveJob # Rails.application.config.active_job.queue_adapter = :sucker_punch class SuckerPunchAdapter def enqueue(job) #:nodoc: - JobWrapper.new.async.perform job.serialize + if JobWrapper.respond_to?(:perform_async) + # sucker_punch 2.0 API + JobWrapper.perform_async job.serialize + else + # sucker_punch 1.0 API + JobWrapper.new.async.perform job.serialize + end end def enqueue_at(job, timestamp) #:nodoc: - raise NotImplementedError, "This queueing backend does not support scheduling jobs. To see what features are supported go to http://api.rubyonrails.org/classes/ActiveJob/QueueAdapters.html" + if JobWrapper.respond_to?(:perform_in) + delay = timestamp - Time.current.to_f + JobWrapper.perform_in delay, job.serialize + else + raise NotImplementedError, 'sucker_punch 1.0 does not support `enqueued_at`. Please upgrade to version ~> 2.0.0 to enable this behavior.' + end end class JobWrapper #:nodoc: |