From 11ab04b11170253e96515c3ada6f2566b092533a Mon Sep 17 00:00:00 2001 From: Terry Meacham Date: Tue, 23 Sep 2014 15:51:44 -0500 Subject: Added queue_name_delimiter attribute. - Added ActiveJob::Base#queue_name_delimiter to allow for developers using ActiveJob to change the delimiter from the default ('_') to whatever else they may be using (e.g., '.', '-', ...). - Updated source guide to include a blurb about the delimiter. --- activejob/lib/active_job/queue_name.rb | 5 ++++- activejob/test/cases/queue_naming_test.rb | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'activejob') diff --git a/activejob/lib/active_job/queue_name.rb b/activejob/lib/active_job/queue_name.rb index d167617e4e..6ee7142ce6 100644 --- a/activejob/lib/active_job/queue_name.rb +++ b/activejob/lib/active_job/queue_name.rb @@ -26,13 +26,16 @@ module ActiveJob def queue_name_from_part(part_name) #:nodoc: queue_name = part_name || default_queue_name name_parts = [queue_name_prefix.presence, queue_name] - name_parts.compact.join('_') + name_parts.compact.join(queue_name_delimiter) end end included do class_attribute :queue_name, instance_accessor: false + class_attribute :queue_name_delimiter, instance_accessor: false + self.queue_name = default_queue_name + self.queue_name_delimiter = '_' # set default delimiter to '_' end # Returns the name of the queue the job will be run on diff --git a/activejob/test/cases/queue_naming_test.rb b/activejob/test/cases/queue_naming_test.rb index 886f41271a..898016a704 100644 --- a/activejob/test/cases/queue_naming_test.rb +++ b/activejob/test/cases/queue_naming_test.rb @@ -64,7 +64,7 @@ class QueueNamingTest < ActiveSupport::TestCase end end - test 'queu_name_prefix prepended to the queue name' do + test 'queue_name_prefix prepended to the queue name with default delimiter' do original_queue_name_prefix = ActiveJob::Base.queue_name_prefix original_queue_name = HelloJob.queue_name @@ -78,6 +78,23 @@ class QueueNamingTest < ActiveSupport::TestCase end end + test 'queue_name_prefix prepended to the queue name with custom delimiter' do + original_queue_name_prefix = ActiveJob::Base.queue_name_prefix + original_queue_name_delimiter = ActiveJob::Base.queue_name_delimiter + original_queue_name = HelloJob.queue_name + + begin + ActiveJob::Base.queue_name_delimiter = '.' + ActiveJob::Base.queue_name_prefix = 'aj' + HelloJob.queue_as :low + assert_equal 'aj.low', HelloJob.queue_name + ensure + ActiveJob::Base.queue_name_prefix = original_queue_name_prefix + ActiveJob::Base.queue_name_delimiter = original_queue_name_delimiter + HelloJob.queue_name = original_queue_name + end + end + test 'uses queue passed to #set' do job = HelloJob.set(queue: :some_queue).perform_later assert_equal "some_queue", job.queue_name -- cgit v1.2.3 From 4daebedcc41e35079c47d5f130f5c7ad12db8bbb Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Thu, 30 Oct 2014 14:09:21 -0700 Subject: Prepare for 4.2.0.beta4 release --- activejob/lib/active_job/gem_version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activejob') diff --git a/activejob/lib/active_job/gem_version.rb b/activejob/lib/active_job/gem_version.rb index f80e6563b8..ac364f77d1 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 = "beta2" + PRE = "beta4" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end -- cgit v1.2.3 From aeb431a6ca7cd05f8d29f454a24bf8f5bd5423ae Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Fri, 31 Oct 2014 19:46:43 +0100 Subject: Tiny documentation improvements [ci skip] --- activejob/lib/active_job/core.rb | 7 ++----- activejob/lib/active_job/enqueuing.rb | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'activejob') diff --git a/activejob/lib/active_job/core.rb b/activejob/lib/active_job/core.rb index f55db5a588..68d46e6466 100644 --- a/activejob/lib/active_job/core.rb +++ b/activejob/lib/active_job/core.rb @@ -48,8 +48,8 @@ module ActiveJob end end - # Creates a new job instance. Takes as arguments the arguments that - # will be passed to the perform method. + # Creates a new job instance. Takes the arguments that will be + # passed to the perform method. def initialize(*arguments) @arguments = arguments @job_id = SecureRandom.uuid @@ -84,6 +84,3 @@ module ActiveJob end end end - - - diff --git a/activejob/lib/active_job/enqueuing.rb b/activejob/lib/active_job/enqueuing.rb index cca0a2a8d6..53d944021a 100644 --- a/activejob/lib/active_job/enqueuing.rb +++ b/activejob/lib/active_job/enqueuing.rb @@ -22,7 +22,7 @@ module ActiveJob end end - # Reschedule the job to be re-executed. This is useful in combination + # Reschedules the job to be re-executed. This is useful in combination # with the +rescue_from+ option. When you rescue an exception from your job # you can ask Active Job to retry performing your job. # @@ -37,6 +37,7 @@ module ActiveJob # rescue_from(ErrorLoadingSite) do # retry_job queue: :low_priority # end + # # def perform(*args) # # raise ErrorLoadingSite if cannot scrape # end -- cgit v1.2.3 From 84f313ab5d47139dcbdc7f2efe8f6c0ccb33522d Mon Sep 17 00:00:00 2001 From: Rishi Jain Date: Sat, 1 Nov 2014 06:13:17 +0530 Subject: added punctuations, and role of queue_adapter module [ci skip] --- activejob/lib/active_job/queue_adapter.rb | 2 ++ activejob/lib/active_job/queue_adapters/delayed_job_adapter.rb | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'activejob') diff --git a/activejob/lib/active_job/queue_adapter.rb b/activejob/lib/active_job/queue_adapter.rb index 4bd28522ab..78b0f1fb78 100644 --- a/activejob/lib/active_job/queue_adapter.rb +++ b/activejob/lib/active_job/queue_adapter.rb @@ -1,6 +1,8 @@ require 'active_job/queue_adapters/inline_adapter' require 'active_support/core_ext/string/inflections' +# The ActionJob::QueueAdapter module is used to load the +# correct adapter. The default queue adapter is the :inline queue. module ActiveJob module QueueAdapter #:nodoc: extend ActiveSupport::Concern diff --git a/activejob/lib/active_job/queue_adapters/delayed_job_adapter.rb b/activejob/lib/active_job/queue_adapters/delayed_job_adapter.rb index 4d27c4fff8..69d9e70de3 100644 --- a/activejob/lib/active_job/queue_adapters/delayed_job_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/delayed_job_adapter.rb @@ -6,10 +6,10 @@ module ActiveJob # # Delayed::Job (or DJ) encapsulates the common pattern of asynchronously # executing longer tasks in the background. Although DJ can have many - # storage backends one of the most used is based on Active Record. + # storage backends, one of the most used is based on Active Record. # Read more about Delayed Job {here}[https://github.com/collectiveidea/delayed_job]. # - # To use Delayed Job set the queue_adapter config to +:delayed_job+. + # To use Delayed Job, set the queue_adapter config to +:delayed_job+. # # Rails.application.config.active_job.queue_adapter = :delayed_job class DelayedJobAdapter -- cgit v1.2.3 From 19f6ac929bff5cb6ae95a26e8da29b20f5c4d146 Mon Sep 17 00:00:00 2001 From: Rishi Jain Date: Sat, 1 Nov 2014 10:29:34 +0530 Subject: placed description at correct place [ci skip] --- activejob/lib/active_job/queue_adapter.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activejob') diff --git a/activejob/lib/active_job/queue_adapter.rb b/activejob/lib/active_job/queue_adapter.rb index 78b0f1fb78..b42ec3b638 100644 --- a/activejob/lib/active_job/queue_adapter.rb +++ b/activejob/lib/active_job/queue_adapter.rb @@ -1,9 +1,9 @@ require 'active_job/queue_adapters/inline_adapter' require 'active_support/core_ext/string/inflections' -# The ActionJob::QueueAdapter module is used to load the -# correct adapter. The default queue adapter is the :inline queue. module ActiveJob + # The ActionJob::QueueAdapter module is used to load the + # correct adapter. The default queue adapter is the :inline queue. module QueueAdapter #:nodoc: extend ActiveSupport::Concern -- cgit v1.2.3 From 30c3813cf0851598aac2f41e51c72a0624e8cf23 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Sat, 1 Nov 2014 19:27:18 +0100 Subject: Tiny documentation fixes and styling improvements [ci skip] --- activejob/lib/active_job/test_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activejob') diff --git a/activejob/lib/active_job/test_helper.rb b/activejob/lib/active_job/test_helper.rb index ade7a94c9d..bb20d93947 100644 --- a/activejob/lib/active_job/test_helper.rb +++ b/activejob/lib/active_job/test_helper.rb @@ -53,7 +53,7 @@ module ActiveJob end end - # Assert that no job have been enqueued. + # Asserts that no jobs have been enqueued. # # def test_jobs # assert_no_enqueued_jobs @@ -137,7 +137,7 @@ module ActiveJob # Asserts that the job passed in the block has been enqueued with the given arguments. # - # def assert_enqueued_job + # def test_assert_enqueued_with # assert_enqueued_with(job: MyJob, args: [1,2,3], queue: 'low') do # MyJob.perform_later(1,2,3) # end -- cgit v1.2.3 From 1d6d0cc2455f65454f7cb8f938204cddf6380e24 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Sun, 2 Nov 2014 12:32:50 +0100 Subject: Tiny documentation styling fixes [ci skip] --- activejob/lib/active_job/queue_adapters.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activejob') diff --git a/activejob/lib/active_job/queue_adapters.rb b/activejob/lib/active_job/queue_adapters.rb index efbcd3cb3a..f22b0502dc 100644 --- a/activejob/lib/active_job/queue_adapters.rb +++ b/activejob/lib/active_job/queue_adapters.rb @@ -13,7 +13,7 @@ module ActiveJob # * {Sneakers}[https://github.com/jondot/sneakers] # * {Sucker Punch}[https://github.com/brandonhilkert/sucker_punch] # - # #### Backends Features + # === Backends Features # # | | Async | Queues | Delayed | Priorities | Timeout | Retries | # |-------------------|-------|--------|-----------|------------|---------|---------| -- cgit v1.2.3 From 797a7a7c833f456987335d02696cc8531df992d3 Mon Sep 17 00:00:00 2001 From: rochefort Date: Tue, 4 Nov 2014 07:00:24 +0900 Subject: Remove redundant `to_s` in interpolation --- activejob/lib/active_job/logging.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activejob') diff --git a/activejob/lib/active_job/logging.rb b/activejob/lib/active_job/logging.rb index 6e703faaa7..21d2fda3ff 100644 --- a/activejob/lib/active_job/logging.rb +++ b/activejob/lib/active_job/logging.rb @@ -75,7 +75,7 @@ module ActiveJob def perform(event) info do job = event.payload[:job] - "Performed #{job.class.name} from #{queue_name(event)} in #{event.duration.round(2).to_s}ms" + "Performed #{job.class.name} from #{queue_name(event)} in #{event.duration.round(2)}ms" end end -- cgit v1.2.3 From dc5854f3829a34288019895b06e86f12a9153e01 Mon Sep 17 00:00:00 2001 From: Zachary Scott Date: Mon, 3 Nov 2014 19:21:43 -0800 Subject: Document the class methods include module for AJ::Callbacks [ci skip] --- activejob/lib/active_job/callbacks.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activejob') diff --git a/activejob/lib/active_job/callbacks.rb b/activejob/lib/active_job/callbacks.rb index 29e2a878b4..46a402b017 100644 --- a/activejob/lib/active_job/callbacks.rb +++ b/activejob/lib/active_job/callbacks.rb @@ -22,6 +22,8 @@ module ActiveJob define_callbacks :enqueue end + # These methods will be included into any Active Job object, adding + # callbacks for `perform` and `enqueue` methods. module ClassMethods # Defines a callback that will get called right before the # job's perform method is executed. -- cgit v1.2.3 From 73161c5744feed7a6d86c18886a7a34fdc61dfb6 Mon Sep 17 00:00:00 2001 From: Zachary Scott Date: Mon, 3 Nov 2014 19:22:11 -0800 Subject: Add documentation for class methods module included for AJ::Core used for serialization and deserialization of jobs. [ci skip] --- activejob/lib/active_job/core.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activejob') diff --git a/activejob/lib/active_job/core.rb b/activejob/lib/active_job/core.rb index 68d46e6466..a0e55a0028 100644 --- a/activejob/lib/active_job/core.rb +++ b/activejob/lib/active_job/core.rb @@ -17,6 +17,8 @@ module ActiveJob attr_writer :queue_name end + # These methods will be included into any Active Job object, adding + # helpers for de/serialization and creation of job instances. module ClassMethods # Creates a new job instance from a hash created with +serialize+ def deserialize(job_data) -- cgit v1.2.3 From c07c0b268e3247ae34e3c5a6f39977b45ec0487f Mon Sep 17 00:00:00 2001 From: Zachary Scott Date: Mon, 3 Nov 2014 19:22:57 -0800 Subject: Document the module which includes `perform_later` for AJ::Enqueuing [ci skip] --- activejob/lib/active_job/enqueuing.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activejob') diff --git a/activejob/lib/active_job/enqueuing.rb b/activejob/lib/active_job/enqueuing.rb index 53d944021a..b87803864c 100644 --- a/activejob/lib/active_job/enqueuing.rb +++ b/activejob/lib/active_job/enqueuing.rb @@ -4,6 +4,7 @@ module ActiveJob module Enqueuing extend ActiveSupport::Concern + # Includes the `perform_later` method for job initialization. module ClassMethods # Push a job onto the queue. The arguments must be legal JSON types # (string, int, float, nil, true, false, hash or array) or -- cgit v1.2.3 From 60fcf60c7b4e6e01e61f7d000812218e50a8bd5d Mon Sep 17 00:00:00 2001 From: Zachary Scott Date: Mon, 3 Nov 2014 19:23:36 -0800 Subject: Document AJ::Execution class methods module [ci skip] --- activejob/lib/active_job/execution.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activejob') diff --git a/activejob/lib/active_job/execution.rb b/activejob/lib/active_job/execution.rb index 7ff857206d..79d232da4a 100644 --- a/activejob/lib/active_job/execution.rb +++ b/activejob/lib/active_job/execution.rb @@ -6,6 +6,7 @@ module ActiveJob extend ActiveSupport::Concern include ActiveSupport::Rescuable + # Includes methods for executing and performing jobs instantly. module ClassMethods # Performs the job immediately. # -- cgit v1.2.3 From 7ea0f26801ba6efe4b21d4fcb46a290b271695cd Mon Sep 17 00:00:00 2001 From: Zachary Scott Date: Mon, 3 Nov 2014 19:25:44 -0800 Subject: Add documentation of AJ::QueueAdapter class methods module [ci skip] --- activejob/lib/active_job/queue_adapter.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activejob') diff --git a/activejob/lib/active_job/queue_adapter.rb b/activejob/lib/active_job/queue_adapter.rb index b42ec3b638..85d7c44bb8 100644 --- a/activejob/lib/active_job/queue_adapter.rb +++ b/activejob/lib/active_job/queue_adapter.rb @@ -7,6 +7,7 @@ module ActiveJob module QueueAdapter #:nodoc: extend ActiveSupport::Concern + # Includes the setter method for changing the active queue adapter. module ClassMethods mattr_reader(:queue_adapter) { ActiveJob::QueueAdapters::InlineAdapter } -- cgit v1.2.3 From b049d792bdd72f485ffe279ba3f518bf4b3e94a7 Mon Sep 17 00:00:00 2001 From: Zachary Scott Date: Mon, 3 Nov 2014 19:26:04 -0800 Subject: Document included ability of AJ::QueueName module for class methods [ci skip] --- activejob/lib/active_job/queue_name.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activejob') diff --git a/activejob/lib/active_job/queue_name.rb b/activejob/lib/active_job/queue_name.rb index 6ee7142ce6..9ae0345120 100644 --- a/activejob/lib/active_job/queue_name.rb +++ b/activejob/lib/active_job/queue_name.rb @@ -2,6 +2,7 @@ module ActiveJob module QueueName extend ActiveSupport::Concern + # Includes the ability to override the default queue name and prefix. module ClassMethods mattr_accessor(:queue_name_prefix) mattr_accessor(:default_queue_name) { "default" } -- cgit v1.2.3 From 77c0256409d48c23b0b208f95191973e8c1dfd7f Mon Sep 17 00:00:00 2001 From: Zachary Scott Date: Mon, 3 Nov 2014 19:31:31 -0800 Subject: Correct fixed-width doc syntax, thanks to @sikachu for pointing it out! From dc5854f and c07c0b2 [ci skip] --- activejob/lib/active_job/callbacks.rb | 2 +- activejob/lib/active_job/enqueuing.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'activejob') diff --git a/activejob/lib/active_job/callbacks.rb b/activejob/lib/active_job/callbacks.rb index 46a402b017..c4ceb484cc 100644 --- a/activejob/lib/active_job/callbacks.rb +++ b/activejob/lib/active_job/callbacks.rb @@ -23,7 +23,7 @@ module ActiveJob end # These methods will be included into any Active Job object, adding - # callbacks for `perform` and `enqueue` methods. + # callbacks for +perform+ and +enqueue+ methods. module ClassMethods # Defines a callback that will get called right before the # job's perform method is executed. diff --git a/activejob/lib/active_job/enqueuing.rb b/activejob/lib/active_job/enqueuing.rb index b87803864c..430c17e1bf 100644 --- a/activejob/lib/active_job/enqueuing.rb +++ b/activejob/lib/active_job/enqueuing.rb @@ -4,7 +4,7 @@ module ActiveJob module Enqueuing extend ActiveSupport::Concern - # Includes the `perform_later` method for job initialization. + # Includes the +perform_later+ method for job initialization. module ClassMethods # Push a job onto the queue. The arguments must be legal JSON types # (string, int, float, nil, true, false, hash or array) or -- cgit v1.2.3