From a9a64c490dd5f5038b05338debe439855323afb5 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Wed, 27 Jan 2016 11:29:18 -0500 Subject: Update ActiveJob adapter for sucker_punch 2.0 This PR includes two changes for 2.0.0: - Breaking API change around `async.perform` --> `perform_async` - New addition of `perform_in`, which now allows end users of the adapter to use the `enqueued_at` public API method. --- activejob/lib/active_job/queue_adapters.rb | 2 +- .../lib/active_job/queue_adapters/sucker_punch_adapter.rb | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'activejob') 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: -- cgit v1.2.3 From 2c131141ca5018f41f85be429a02afac93a0241d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 27 Jan 2016 15:44:26 -0500 Subject: Remove celluloid from the Gemfile --- activejob/test/support/integration/adapters/sidekiq.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'activejob') diff --git a/activejob/test/support/integration/adapters/sidekiq.rb b/activejob/test/support/integration/adapters/sidekiq.rb index 9aa07bcb52..2f19d7dacc 100644 --- a/activejob/test/support/integration/adapters/sidekiq.rb +++ b/activejob/test/support/integration/adapters/sidekiq.rb @@ -26,7 +26,7 @@ module SidekiqJobsManager continue_read.close death_write.close - # Celluloid & Sidekiq are not warning-clean :( + # Sidekiq is not warning-clean :( $VERBOSE = false $stdin.reopen('/dev/null') @@ -49,8 +49,6 @@ module SidekiqJobsManager self_write.puts("TERM") end - require 'celluloid' - Celluloid.logger = nil require 'sidekiq/launcher' sidekiq = Sidekiq::Launcher.new({queues: ["integration_tests"], environment: "test", -- cgit v1.2.3 From 0db5882bb09231f3d7ae40e3554eb67599b11d57 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Wed, 27 Jan 2016 16:07:46 -0500 Subject: Update sucker_punch adapter's description [ci skip] --- .../lib/active_job/queue_adapters/sucker_punch_adapter.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'activejob') 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 1037084341..311109e958 100644 --- a/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb @@ -5,12 +5,10 @@ module ActiveJob # == Sucker Punch adapter for Active Job # # Sucker Punch is a single-process Ruby asynchronous processing library. - # It's girl_friday and DSL sugar on top of Celluloid. With Celluloid's - # actor pattern, we can do asynchronous processing within a single process. - # This reduces costs of hosting on a service like Heroku along with the - # memory footprint of having to maintain additional jobs if hosting on - # a dedicated server. All queues can run within a single Rails/Sinatra - # process. + # This reduces the cost of of hosting on a service like Heroku along + # with the memory footprint of having to maintain additional jobs if + # hosting on a dedicated server. All queues can run within a + # single application (eg. Rails, Sinatra, etc.) process. # # Read more about Sucker Punch {here}[https://github.com/brandonhilkert/sucker_punch]. # -- cgit v1.2.3 From d6f2000a67cc63aa67414c75ce77de671824ec52 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Mon, 1 Feb 2016 04:31:03 +1030 Subject: Wrangle the asset build into something that sounds more general --- activejob/Rakefile | 3 +++ 1 file changed, 3 insertions(+) (limited to 'activejob') diff --git a/activejob/Rakefile b/activejob/Rakefile index d9648a7f16..2a853b4b6b 100644 --- a/activejob/Rakefile +++ b/activejob/Rakefile @@ -6,6 +6,9 @@ ACTIVEJOB_ADAPTERS -= %w(queue_classic) if defined?(JRUBY_VERSION) task default: :test task test: 'test:default' +task :package +task "package:clean" + namespace :test do desc 'Run all adapter tests' task :default do -- cgit v1.2.3 From 49f6ce63f33b7817bcbd0cdf5f8881b63f40d9c9 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Mon, 1 Feb 2016 14:27:38 -0700 Subject: Preparing for Rails 5.0.0.beta2 --- activejob/CHANGELOG.md | 5 +++++ activejob/lib/active_job/gem_version.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'activejob') diff --git a/activejob/CHANGELOG.md b/activejob/CHANGELOG.md index 8687af5eba..981b6a20ec 100644 --- a/activejob/CHANGELOG.md +++ b/activejob/CHANGELOG.md @@ -1,3 +1,8 @@ +## Rails 5.0.0.beta2 (February 01, 2016) ## + +* No changes. + + ## Rails 5.0.0.beta1 (December 18, 2015) ## * Fixed serializing `:at` option for `assert_enqueued_with` diff --git a/activejob/lib/active_job/gem_version.rb b/activejob/lib/active_job/gem_version.rb index 0bdeca76a8..bc88221027 100644 --- a/activejob/lib/active_job/gem_version.rb +++ b/activejob/lib/active_job/gem_version.rb @@ -8,7 +8,7 @@ module ActiveJob MAJOR = 5 MINOR = 0 TINY = 0 - PRE = "beta1.1" + PRE = "beta2" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end -- cgit v1.2.3 From 625baa69d14881ac49ba2e5c7d9cac4b222d7022 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 5 Feb 2016 15:35:37 +0100 Subject: Change the default adapter from inline to async --- activejob/CHANGELOG.md | 7 +++++++ activejob/lib/active_job/queue_adapter.rb | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'activejob') diff --git a/activejob/CHANGELOG.md b/activejob/CHANGELOG.md index 981b6a20ec..229ef03879 100644 --- a/activejob/CHANGELOG.md +++ b/activejob/CHANGELOG.md @@ -1,3 +1,10 @@ +* Change the default adapter from inline to async. It's a better default as tests will then not mistakenly + come to rely on behavior happening synchronously. This is especially important with things like jobs kicked off + in Active Record lifecycle callbacks. + + *DHH* + + ## Rails 5.0.0.beta2 (February 01, 2016) ## * No changes. diff --git a/activejob/lib/active_job/queue_adapter.rb b/activejob/lib/active_job/queue_adapter.rb index 457015b741..7dfdd0ae5c 100644 --- a/activejob/lib/active_job/queue_adapter.rb +++ b/activejob/lib/active_job/queue_adapter.rb @@ -10,19 +10,19 @@ module ActiveJob included do class_attribute :_queue_adapter, instance_accessor: false, instance_predicate: false - self.queue_adapter = :inline + self.queue_adapter = :async end # Includes the setter method for changing the active queue adapter. module ClassMethods # Returns the backend queue provider. The default queue adapter - # is the +:inline+ queue. See QueueAdapters for more information. + # is the +:async+ queue. See QueueAdapters for more information. def queue_adapter _queue_adapter end # Specify the backend queue provider. The default queue adapter - # is the +:inline+ queue. See QueueAdapters for more + # is the +:async+ queue. See QueueAdapters for more # information. def queue_adapter=(name_or_adapter_or_class) self._queue_adapter = interpret_adapter(name_or_adapter_or_class) -- cgit v1.2.3 From 439fadf758f6f0bc50e3d8c6f96b0ddbd613d299 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 5 Feb 2016 16:05:48 +0100 Subject: Missed a few spots in inline -> async switch --- activejob/README.md | 7 +------ activejob/lib/active_job/queue_adapter.rb | 2 +- activejob/lib/active_job/railtie.rb | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) (limited to 'activejob') diff --git a/activejob/README.md b/activejob/README.md index 7268186c00..8becac7753 100644 --- a/activejob/README.md +++ b/activejob/README.md @@ -20,12 +20,7 @@ switch between them without having to rewrite your jobs. ## Usage -Set the queue adapter for Active Job: - -``` ruby -ActiveJob::Base.queue_adapter = :inline # default queue adapter -``` -Note: To learn how to use your preferred queueing backend see its adapter +To learn how to use your preferred queueing backend see its adapter documentation at [ActiveJob::QueueAdapters](http://api.rubyonrails.org/classes/ActiveJob/QueueAdapters.html). diff --git a/activejob/lib/active_job/queue_adapter.rb b/activejob/lib/active_job/queue_adapter.rb index 7dfdd0ae5c..72e4ebf935 100644 --- a/activejob/lib/active_job/queue_adapter.rb +++ b/activejob/lib/active_job/queue_adapter.rb @@ -4,7 +4,7 @@ require 'active_support/core_ext/string/inflections' module ActiveJob # The ActiveJob::QueueAdapter module is used to load the - # correct adapter. The default queue adapter is the +:inline+ queue. + # correct adapter. The default queue adapter is the +:async+ queue. module QueueAdapter #:nodoc: extend ActiveSupport::Concern diff --git a/activejob/lib/active_job/railtie.rb b/activejob/lib/active_job/railtie.rb index 6538ac1b30..b249ec09dd 100644 --- a/activejob/lib/active_job/railtie.rb +++ b/activejob/lib/active_job/railtie.rb @@ -12,7 +12,7 @@ module ActiveJob initializer "active_job.set_configs" do |app| options = app.config.active_job - options.queue_adapter ||= :inline + options.queue_adapter ||= :async ActiveSupport.on_load(:active_job) do options.each { |k,v| send("#{k}=", v) } -- cgit v1.2.3 From 6809758bc65825966bcf9dd1f716e4332724b609 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sun, 7 Feb 2016 09:12:19 +0900 Subject: fix typo in `assert_enqueued_jobs` example [ci skip] --- activejob/lib/active_job/test_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activejob') diff --git a/activejob/lib/active_job/test_helper.rb b/activejob/lib/active_job/test_helper.rb index 44ddfa5f69..ed0c05c1e5 100644 --- a/activejob/lib/active_job/test_helper.rb +++ b/activejob/lib/active_job/test_helper.rb @@ -58,7 +58,7 @@ module ActiveJob # The number of times a specific job is enqueued can be asserted. # # def test_logging_job - # assert_enqueued_jobs 2, only: LoggingJob do + # assert_enqueued_jobs 1, only: LoggingJob do # LoggingJob.perform_later # HelloJob.perform_later('jeremy') # end -- cgit v1.2.3