From d694ea259c755924ba54e8e3783630ae3d737543 Mon Sep 17 00:00:00 2001 From: Logan Hasson Date: Wed, 20 Aug 2014 15:36:58 -0400 Subject: [ci skip] Fix Active Job grammar in api docs --- activejob/lib/active_job/callbacks.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activejob/lib') diff --git a/activejob/lib/active_job/callbacks.rb b/activejob/lib/active_job/callbacks.rb index af92031bc9..8901fa77f2 100644 --- a/activejob/lib/active_job/callbacks.rb +++ b/activejob/lib/active_job/callbacks.rb @@ -3,7 +3,7 @@ require 'active_support/callbacks' module ActiveJob # = Active Job Callbacks # - # Active Job provides hooks during the lifecycle of a job. Callbacks allows you to trigger + # Active Job provides hooks during the lifecycle of a job. Callbacks allow you to trigger # logic during the lifecycle of a job. Available callbacks: # # * before_enqueue -- cgit v1.2.3 From 9b319a53fa880a2407c4836a25f3637d4891fad9 Mon Sep 17 00:00:00 2001 From: Nicholas Bruning Date: Thu, 21 Aug 2014 04:19:40 +0000 Subject: Added enqueue_at support for QueAdapter in ActiveJob * Added inline job runner for Que in test/support * Updated QueAdapter to support enqueue_at --- activejob/lib/active_job/queue_adapters/que_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activejob/lib') diff --git a/activejob/lib/active_job/queue_adapters/que_adapter.rb b/activejob/lib/active_job/queue_adapters/que_adapter.rb index 0b87deb4e0..9c84c74f83 100644 --- a/activejob/lib/active_job/queue_adapters/que_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/que_adapter.rb @@ -9,7 +9,7 @@ module ActiveJob end def enqueue_at(job, timestamp, *args) - raise NotImplementedError + JobWrapper.enqueue job.name, *args, queue: job.queue_name, run_at: Time.at(timestamp) end end -- cgit v1.2.3 From a57f7b57976c74dd76c911f867b76197119546e6 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Thu, 21 Aug 2014 23:27:40 +0200 Subject: ActiveJob -> Active Job [ci skip] See http://guides.rubyonrails.org/api_documentation_guidelines.html#wording --- activejob/lib/active_job/gem_version.rb | 2 +- activejob/lib/active_job/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'activejob/lib') diff --git a/activejob/lib/active_job/gem_version.rb b/activejob/lib/active_job/gem_version.rb index c166020b28..2545e09845 100644 --- a/activejob/lib/active_job/gem_version.rb +++ b/activejob/lib/active_job/gem_version.rb @@ -1,5 +1,5 @@ module ActiveJob - # Returns the version of the currently loaded ActiveJob as a Gem::Version + # Returns the version of the currently loaded Active Job as a Gem::Version def self.gem_version Gem::Version.new VERSION::STRING end diff --git a/activejob/lib/active_job/version.rb b/activejob/lib/active_job/version.rb index 7e646fa3c4..971ba9fe0c 100644 --- a/activejob/lib/active_job/version.rb +++ b/activejob/lib/active_job/version.rb @@ -1,7 +1,7 @@ require_relative 'gem_version' module ActiveJob - # Returns the version of the currently loaded ActiveJob as a Gem::Version + # Returns the version of the currently loaded Active Job as a Gem::Version def self.version gem_version end -- cgit v1.2.3 From fb740239dc0ea7e543388f057e205c68b67a449c Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 22 Aug 2014 17:47:13 +0800 Subject: Pass logging message through block. This follows the good practice listed on http://guides.rubyonrails.org/debugging_rails_applications.html#impact-of-logs-on-performance --- activejob/lib/active_job/logging.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'activejob/lib') diff --git a/activejob/lib/active_job/logging.rb b/activejob/lib/active_job/logging.rb index d9e544acf5..ae098a80f3 100644 --- a/activejob/lib/active_job/logging.rb +++ b/activejob/lib/active_job/logging.rb @@ -52,19 +52,19 @@ module ActiveJob class LogSubscriber < ActiveSupport::LogSubscriber def enqueue(event) - info "Enqueued #{event.payload[:job].name} (Job ID: #{event.payload[:job_id]}) to #{queue_name(event)}" + args_info(event) + info { "Enqueued #{event.payload[:job].name} (Job ID: #{event.payload[:job_id]}) to #{queue_name(event)}" + args_info(event) } end def enqueue_at(event) - info "Enqueued #{event.payload[:job].name} (Job ID: #{event.payload[:job_id]}) to #{queue_name(event)} at #{enqueued_at(event)}" + args_info(event) + info { "Enqueued #{event.payload[:job].name} (Job ID: #{event.payload[:job_id]}) to #{queue_name(event)} at #{enqueued_at(event)}" + args_info(event) } end def perform_start(event) - info "Performing #{event.payload[:job].name} from #{queue_name(event)}" + args_info(event) + info { "Performing #{event.payload[:job].name} from #{queue_name(event)}" + args_info(event) } end def perform(event) - info "Performed #{event.payload[:job].name} from #{queue_name(event)} in #{event.duration.round(2).to_s}ms" + info { "Performed #{event.payload[:job].name} from #{queue_name(event)} in #{event.duration.round(2).to_s}ms" } end private -- cgit v1.2.3 From e084d5bd7aaa113f29b4ea8d0f2305daeae33826 Mon Sep 17 00:00:00 2001 From: Cristian Bica Date: Fri, 22 Aug 2014 17:44:48 +0300 Subject: Implemented enqueue_at for ActiveJob's Backburner adapter --- activejob/lib/active_job/queue_adapters/backburner_adapter.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activejob/lib') diff --git a/activejob/lib/active_job/queue_adapters/backburner_adapter.rb b/activejob/lib/active_job/queue_adapters/backburner_adapter.rb index 6fe2d4eb53..8d34155645 100644 --- a/activejob/lib/active_job/queue_adapters/backburner_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/backburner_adapter.rb @@ -9,7 +9,8 @@ module ActiveJob end def enqueue_at(job, timestamp, *args) - raise NotImplementedError + delay = Time.current.to_f - timestamp + Backburner::Worker.enqueue JobWrapper, [ job.name, *args ], queue: job.queue_name, delay: delay end end -- cgit v1.2.3 From e63a02ccfbbdc0aeefd57617c835a2adc8588dd3 Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Fri, 22 Aug 2014 19:30:36 +0000 Subject: [ActiveJob] Add hook for test_framework and test templates --- activejob/lib/rails/generators/job/job_generator.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'activejob/lib') diff --git a/activejob/lib/rails/generators/job/job_generator.rb b/activejob/lib/rails/generators/job/job_generator.rb index 78a9c27606..979ffcb748 100644 --- a/activejob/lib/rails/generators/job/job_generator.rb +++ b/activejob/lib/rails/generators/job/job_generator.rb @@ -7,12 +7,14 @@ module Rails class_option :queue, type: :string, default: 'default', desc: 'The queue name for the generated job' + check_class_collision suffix: 'Job' + + hook_for :test_framework + def self.default_generator_root File.dirname(__FILE__) end - check_class_collision suffix: 'Job' - def create_job_file template 'job.rb', File.join('app/jobs', class_path, "#{file_name}_job.rb") end -- cgit v1.2.3 From 23329d33d45c7388d33c6080820927b96fb34890 Mon Sep 17 00:00:00 2001 From: Cristian Bica Date: Sat, 23 Aug 2014 14:19:44 +0300 Subject: Raise ActiveJob::SerializationError when cannot serialize job arguments --- activejob/lib/active_job/arguments.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'activejob/lib') diff --git a/activejob/lib/active_job/arguments.rb b/activejob/lib/active_job/arguments.rb index 369e716912..ccee4ab35b 100644 --- a/activejob/lib/active_job/arguments.rb +++ b/activejob/lib/active_job/arguments.rb @@ -1,4 +1,7 @@ module ActiveJob + # Raised when an exception is raised during job arguments deserialization. + # + # Wraps the original exception raised as +original_exception+. class DeserializationError < StandardError attr_reader :original_exception @@ -9,6 +12,14 @@ module ActiveJob end end + # Raised when an unsupporter argument type is being set as job argument. We + # currently support NilClass, Fixnum, Float, String, TrueClass, FalseClass, + # Bignum and object that can be represented as GlobalIDs (ex: Active Record). + # Also raised if you set the key for a Hash something else than a string or + # a symbol. + class SerializationError < ArgumentError + end + module Arguments extend self TYPE_WHITELIST = [ NilClass, Fixnum, Float, String, TrueClass, FalseClass, Bignum ] @@ -33,7 +44,7 @@ module ActiveJob when Hash Hash[ argument.map { |key, value| [ serialize_hash_key(key), serialize_argument(value) ] } ] else - raise "Unsupported argument type: #{argument.class.name}" + raise SerializationError.new("Unsupported argument type: #{argument.class.name}") end end @@ -55,7 +66,7 @@ module ActiveJob when String, Symbol key.to_s else - raise "Unsupported hash key type: #{key.class.name}" + raise SerializationError.new("Unsupported hash key type: #{key.class.name}") end end end -- cgit v1.2.3 From f3b8a0d375fe441d70b9c77bd9c20347c71a70cb Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Sun, 24 Aug 2014 18:33:59 +0200 Subject: Fix a few typos [ci skip] --- activejob/lib/active_job/arguments.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activejob/lib') diff --git a/activejob/lib/active_job/arguments.rb b/activejob/lib/active_job/arguments.rb index ccee4ab35b..e54f4afbc7 100644 --- a/activejob/lib/active_job/arguments.rb +++ b/activejob/lib/active_job/arguments.rb @@ -12,7 +12,7 @@ module ActiveJob end end - # Raised when an unsupporter argument type is being set as job argument. We + # Raised when an unsupported argument type is being set as job argument. We # currently support NilClass, Fixnum, Float, String, TrueClass, FalseClass, # Bignum and object that can be represented as GlobalIDs (ex: Active Record). # Also raised if you set the key for a Hash something else than a string or -- cgit v1.2.3 From 7e99855dee8db2bf155a502fb3110f47487fcbdd Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Tue, 26 Aug 2014 12:22:59 +0000 Subject: [ActiveJob] Autoload adapters --- activejob/lib/active_job.rb | 3 ++- activejob/lib/active_job/queue_adapter.rb | 1 - activejob/lib/active_job/queue_adapters.rb | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 activejob/lib/active_job/queue_adapters.rb (limited to 'activejob/lib') 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/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 -- cgit v1.2.3 From 38d6c722b23bae2eeb82a63fc1e78c0937bed17a Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Fri, 29 Aug 2014 12:36:45 +0200 Subject: Some documentation fixes [ci skip] --- activejob/lib/active_job/callbacks.rb | 4 ++-- activejob/lib/active_job/gem_version.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'activejob/lib') 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: # # * before_enqueue # * around_enqueue diff --git a/activejob/lib/active_job/gem_version.rb b/activejob/lib/active_job/gem_version.rb index 2545e09845..c166020b28 100644 --- a/activejob/lib/active_job/gem_version.rb +++ b/activejob/lib/active_job/gem_version.rb @@ -1,5 +1,5 @@ module ActiveJob - # Returns the version of the currently loaded Active Job as a Gem::Version + # Returns the version of the currently loaded ActiveJob as a Gem::Version def self.gem_version Gem::Version.new VERSION::STRING end -- cgit v1.2.3 From 02b63a5f9e441a02b6e22ad8b3f8e66c10a996fc Mon Sep 17 00:00:00 2001 From: Cristian Bica Date: Sat, 30 Aug 2014 00:04:01 +0300 Subject: Fixed Active Job Backburner adapter --- activejob/lib/active_job/queue_adapters/backburner_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activejob/lib') 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 -- cgit v1.2.3