diff options
Diffstat (limited to 'activejob')
-rw-r--r-- | activejob/lib/active_job.rb | 3 | ||||
-rw-r--r-- | activejob/lib/active_job/callbacks.rb | 4 | ||||
-rw-r--r-- | activejob/lib/active_job/gem_version.rb | 2 | ||||
-rw-r--r-- | activejob/lib/active_job/queue_adapter.rb | 1 | ||||
-rw-r--r-- | activejob/lib/active_job/queue_adapters.rb | 16 | ||||
-rw-r--r-- | activejob/lib/active_job/queue_adapters/backburner_adapter.rb | 2 | ||||
-rw-r--r-- | activejob/test/helper.rb | 30 | ||||
-rw-r--r-- | activejob/test/jobs/gid_job.rb | 2 | ||||
-rw-r--r-- | activejob/test/jobs/hello_job.rb | 2 | ||||
-rw-r--r-- | activejob/test/jobs/rescue_job.rb | 2 | ||||
-rw-r--r-- | activejob/test/support/job_buffer.rb | 19 |
11 files changed, 49 insertions, 34 deletions
diff --git a/activejob/lib/active_job.rb b/activejob/lib/active_job.rb index ef92406725..29123170b8 100644 --- a/activejob/lib/active_job.rb +++ b/activejob/lib/active_job.rb @@ -30,4 +30,5 @@ module ActiveJob extend ActiveSupport::Autoload autoload :Base -end
\ No newline at end of file + autoload :QueueAdapters +end diff --git a/activejob/lib/active_job/callbacks.rb b/activejob/lib/active_job/callbacks.rb index 8901fa77f2..cafa3438c0 100644 --- a/activejob/lib/active_job/callbacks.rb +++ b/activejob/lib/active_job/callbacks.rb @@ -3,8 +3,8 @@ require 'active_support/callbacks' module ActiveJob # = Active Job Callbacks # - # Active Job provides hooks during the lifecycle of a job. Callbacks allow you to trigger - # logic during the lifecycle of a job. Available callbacks: + # Active Job provides hooks during the lifecycle of a job. Callbacks allow you + # to trigger logic during the lifecycle of a job. Available callbacks are: # # * <tt>before_enqueue</tt> # * <tt>around_enqueue</tt> diff --git a/activejob/lib/active_job/gem_version.rb b/activejob/lib/active_job/gem_version.rb index 2545e09845..1f25d48326 100644 --- a/activejob/lib/active_job/gem_version.rb +++ b/activejob/lib/active_job/gem_version.rb @@ -8,7 +8,7 @@ module ActiveJob MAJOR = 4 MINOR = 2 TINY = 0 - PRE = "alpha" + PRE = "beta1" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/activejob/lib/active_job/queue_adapter.rb b/activejob/lib/active_job/queue_adapter.rb index 8f2f8b86ea..13c23abce4 100644 --- a/activejob/lib/active_job/queue_adapter.rb +++ b/activejob/lib/active_job/queue_adapter.rb @@ -17,7 +17,6 @@ module ActiveJob private def load_adapter(name) - require "active_job/queue_adapters/#{name}_adapter" "ActiveJob::QueueAdapters::#{name.to_s.camelize}Adapter".constantize end end diff --git a/activejob/lib/active_job/queue_adapters.rb b/activejob/lib/active_job/queue_adapters.rb new file mode 100644 index 0000000000..007068ff0a --- /dev/null +++ b/activejob/lib/active_job/queue_adapters.rb @@ -0,0 +1,16 @@ +module ActiveJob + module QueueAdapters + extend ActiveSupport::Autoload + + autoload :InlineAdapter + autoload :BackburnerAdapter + autoload :DelayedJobAdapter + autoload :QuAdapter + autoload :QueAdapter + autoload :QueueClassicAdapter + autoload :ResqueAdapter + autoload :SidekiqAdapter + autoload :SneakersAdapter + autoload :SuckerPunchAdapter + end +end diff --git a/activejob/lib/active_job/queue_adapters/backburner_adapter.rb b/activejob/lib/active_job/queue_adapters/backburner_adapter.rb index 8d34155645..8ebee36e45 100644 --- a/activejob/lib/active_job/queue_adapters/backburner_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/backburner_adapter.rb @@ -9,7 +9,7 @@ module ActiveJob end def enqueue_at(job, timestamp, *args) - delay = Time.current.to_f - timestamp + delay = timestamp - Time.current.to_f Backburner::Worker.enqueue JobWrapper, [ job.name, *args ], queue: job.queue_name, delay: delay end end diff --git a/activejob/test/helper.rb b/activejob/test/helper.rb index ca67700273..85094387ef 100644 --- a/activejob/test/helper.rb +++ b/activejob/test/helper.rb @@ -10,41 +10,15 @@ def sidekiq? @adapter == 'sidekiq' end -def rubinius? - RUBY_ENGINE == 'rbx' -end - def ruby_193? RUBY_VERSION == '1.9.3' && RUBY_ENGINE != 'java' end -#Sidekiq don't work with MRI 1.9.3 -#Travis uses rbx 2.6 which don't support unicode characters in methods. -#Remove the check when Travis change to rbx 2.7+ -exit if sidekiq? && (ruby_193? || rubinius?) +# Sidekiq doesn't work with MRI 1.9.3 +exit if sidekiq? && ruby_193? require "adapters/#{@adapter}" require 'active_support/testing/autorun' ActiveJob::Base.logger.level = Logger::DEBUG - -module JobBuffer - class << self - def clear - @buffer = [] - end - - def add(value) - @buffer << value - end - - def values - @buffer - end - - def last_value - @buffer.last - end - end -end diff --git a/activejob/test/jobs/gid_job.rb b/activejob/test/jobs/gid_job.rb index 35c2366ec4..e485bfa2dd 100644 --- a/activejob/test/jobs/gid_job.rb +++ b/activejob/test/jobs/gid_job.rb @@ -1,3 +1,5 @@ +require_relative '../support/job_buffer' + class GidJob < ActiveJob::Base def perform(person) JobBuffer.add("Person with ID: #{person.id}") diff --git a/activejob/test/jobs/hello_job.rb b/activejob/test/jobs/hello_job.rb index 4c6256af0d..022fa58e4a 100644 --- a/activejob/test/jobs/hello_job.rb +++ b/activejob/test/jobs/hello_job.rb @@ -1,3 +1,5 @@ +require_relative '../support/job_buffer' + class HelloJob < ActiveJob::Base def perform(greeter = "David") JobBuffer.add("#{greeter} says hello") diff --git a/activejob/test/jobs/rescue_job.rb b/activejob/test/jobs/rescue_job.rb index e9cb37d1c4..6b6e74e9d0 100644 --- a/activejob/test/jobs/rescue_job.rb +++ b/activejob/test/jobs/rescue_job.rb @@ -1,3 +1,5 @@ +require_relative '../support/job_buffer' + class RescueJob < ActiveJob::Base class OtherError < StandardError; end diff --git a/activejob/test/support/job_buffer.rb b/activejob/test/support/job_buffer.rb new file mode 100644 index 0000000000..620cb5288d --- /dev/null +++ b/activejob/test/support/job_buffer.rb @@ -0,0 +1,19 @@ +module JobBuffer + class << self + def clear + values.clear + end + + def add(value) + values << value + end + + def values + @values ||= [] + end + + def last_value + values.last + end + end +end |