activejob 7.0.0.alpha1 → 7.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34ec9d3dc4bb88ce5c06f50a5efb7d34fb383b38088a400a1dc307329be429a9
4
- data.tar.gz: 8d2a9541a56b633fabb47adbf164d6568f7487ab07f5749e96917320c5f66b0a
3
+ metadata.gz: 76df0430ea7f5eadb7780020ffc50c075fdc64b39a3cda073da2bfe4f44a2e58
4
+ data.tar.gz: 53d24d3b2274f2546ce40986ba8e8bacd4afd1b3c5fc809b98562bbe51cec989
5
5
  SHA512:
6
- metadata.gz: 52b3116d2eba23f548e2af97a90a31fb544a0bb8c53e2642b6d0d8cdc03d419dc2de8bac6243b409b32d15fbf1af4da42e356f19df765d6b708b5b55b7283bb9
7
- data.tar.gz: b8f3195cf56348deed886b834fe67a9f036b931f7b93c386888411d6aabc84467d87fc0a56ac2263b9d21df0e8294a3438d80e0748099ec1bd28bfcd4940c96e
6
+ metadata.gz: 3971cc1118a54d061425cbb011f0c1a77d7dc06b892be34f3b692c6644495346dbbdfdc30fd4daba59ea8c2dc0f4c23a45c6e5222999eae202aecd8e6bca405f
7
+ data.tar.gz: 490a6b13ef22e5a380208ff3bf9c74f81713efe159a26a3730cc9550d4664a4ee99f7970641c02d0e9b2dc0ddcfa0f192229c20913379ae82e8c1a17c2f50ea8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,34 @@
1
+ ## Rails 7.0.0.rc3 (December 14, 2021) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 7.0.0.rc2 (December 14, 2021) ##
7
+
8
+ * Remove deprecated `:return_false_on_aborted_enqueue` option.
9
+
10
+ *Rafael Mendonça França*
11
+
12
+ * Deprecated `Rails.config.active_job.skip_after_callbacks_if_terminated`.
13
+
14
+ *Rafael Mendonça França*
15
+
16
+ * Removed deprecated behavior that was not halting `after_enqueue`/`after_perform` callbacks when a
17
+ previous callback was halted with `throw :abort`.
18
+
19
+ *Rafael Mendonça França*
20
+
21
+ * Raise an `SerializationError` in `Serializer::ModuleSerializer`
22
+ if the module name is not present.
23
+
24
+ *Veerpal Brar*
25
+
26
+
27
+ ## Rails 7.0.0.alpha2 (September 15, 2021) ##
28
+
29
+ * No changes.
30
+
31
+
1
32
  ## Rails 7.0.0.alpha1 (September 15, 2021) ##
2
33
 
3
34
  * Allow a job to retry indefinitely
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/callbacks"
4
- require "active_support/core_ext/object/with_options"
5
4
  require "active_support/core_ext/module/attribute_accessors"
6
5
 
7
6
  module ActiveJob
@@ -30,24 +29,16 @@ module ActiveJob
30
29
 
31
30
  included do
32
31
  class_attribute :return_false_on_aborted_enqueue, instance_accessor: false, instance_predicate: false, default: false
33
- singleton_class.deprecate :return_false_on_aborted_enqueue, :return_false_on_aborted_enqueue=
34
32
  cattr_accessor :skip_after_callbacks_if_terminated, instance_accessor: false, default: false
33
+ singleton_class.deprecate :skip_after_callbacks_if_terminated, :skip_after_callbacks_if_terminated=
35
34
 
36
- with_options(skip_after_callbacks_if_terminated: skip_after_callbacks_if_terminated) do
37
- define_callbacks :perform
38
- define_callbacks :enqueue
39
- end
35
+ define_callbacks :perform, skip_after_callbacks_if_terminated: true
36
+ define_callbacks :enqueue, skip_after_callbacks_if_terminated: true
40
37
  end
41
38
 
42
39
  # These methods will be included into any Active Job object, adding
43
40
  # callbacks for +perform+ and +enqueue+ methods.
44
41
  module ClassMethods
45
- def inherited(klass)
46
- klass.get_callbacks(:enqueue).config[:skip_after_callbacks_if_terminated] = skip_after_callbacks_if_terminated
47
- klass.get_callbacks(:perform).config[:skip_after_callbacks_if_terminated] = skip_after_callbacks_if_terminated
48
- super
49
- end
50
-
51
42
  # Defines a callback that will get called right before the
52
43
  # job's perform method is executed.
53
44
  #
@@ -178,21 +169,5 @@ module ActiveJob
178
169
  set_callback(:enqueue, :around, *filters, &blk)
179
170
  end
180
171
  end
181
-
182
- private
183
- def halted_callback_hook(_filter, name) # :nodoc:
184
- return super unless %i(enqueue perform).include?(name.to_sym)
185
- callbacks = public_send("_#{name}_callbacks")
186
-
187
- if !self.class.skip_after_callbacks_if_terminated && callbacks.any? { |c| c.kind == :after }
188
- ActiveSupport::Deprecation.warn(<<~EOM)
189
- In Rails 7.0, `after_enqueue`/`after_perform` callbacks no longer run if `before_enqueue`/`before_perform` respectively halts with `throw :abort`.
190
- To enable this behavior, uncomment the `config.active_job.skip_after_callbacks_if_terminated` config
191
- in the new 6.1 framework defaults initializer.
192
- EOM
193
- end
194
-
195
- super
196
- end
197
172
  end
198
173
  end
@@ -8,7 +8,7 @@ module ActiveJob
8
8
  end
9
9
 
10
10
  def perform_now(...)
11
- @job_class.new(...).perform_now
11
+ @job_class.new(...).set(@options).perform_now
12
12
  end
13
13
 
14
14
  def perform_later(...)
@@ -156,6 +156,16 @@ module ActiveJob
156
156
  self.enqueued_at = job_data["enqueued_at"]
157
157
  end
158
158
 
159
+ # Configures the job with the given options.
160
+ def set(options = {}) # :nodoc:
161
+ self.scheduled_at = options[:wait].seconds.from_now.to_f if options[:wait]
162
+ self.scheduled_at = options[:wait_until].to_f if options[:wait_until]
163
+ self.queue_name = self.class.queue_name_from_part(options[:queue]) if options[:queue]
164
+ self.priority = options[:priority].to_i if options[:priority]
165
+
166
+ self
167
+ end
168
+
159
169
  private
160
170
  def serialize_arguments_if_needed(arguments)
161
171
  if arguments_serialized?
@@ -57,10 +57,7 @@ module ActiveJob
57
57
  # my_job_instance.enqueue wait_until: Date.tomorrow.midnight
58
58
  # my_job_instance.enqueue priority: 10
59
59
  def enqueue(options = {})
60
- self.scheduled_at = options[:wait].seconds.from_now.to_f if options[:wait]
61
- self.scheduled_at = options[:wait_until].to_f if options[:wait_until]
62
- self.queue_name = self.class.queue_name_from_part(options[:queue]) if options[:queue]
63
- self.priority = options[:priority].to_i if options[:priority]
60
+ set(options)
64
61
  self.successfully_enqueued = false
65
62
 
66
63
  run_callbacks :enqueue do
@@ -54,6 +54,7 @@ module ActiveJob
54
54
 
55
55
  private
56
56
  def _perform_job
57
+ ActiveSupport::ExecutionContext[:job] = self
57
58
  run_callbacks :perform do
58
59
  perform(*arguments)
59
60
  end
@@ -10,7 +10,7 @@ module ActiveJob
10
10
  MAJOR = 7
11
11
  MINOR = 0
12
12
  TINY = 0
13
- PRE = "alpha1"
13
+ PRE = "rc3"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -65,12 +65,8 @@ module ActiveJob
65
65
  if query_logs_tags_enabled
66
66
  app.config.active_record.query_log_tags << :job
67
67
 
68
- ActiveSupport.on_load(:active_job) do
69
- include ActiveJob::QueryTags
70
- end
71
-
72
68
  ActiveSupport.on_load(:active_record) do
73
- ActiveRecord::QueryLogs.taggings[:job] = ->(context) { context[:job].class.name unless context[:job].nil? }
69
+ ActiveRecord::QueryLogs.taggings[:job] = ->(context) { context[:job].class.name if context[:job] }
74
70
  end
75
71
  end
76
72
  end
@@ -4,6 +4,7 @@ module ActiveJob
4
4
  module Serializers
5
5
  class ModuleSerializer < ObjectSerializer # :nodoc:
6
6
  def serialize(constant)
7
+ raise SerializationError, "Serializing an anonymous class is not supported" unless constant.name
7
8
  super("value" => constant.name)
8
9
  end
9
10
 
@@ -109,7 +109,7 @@ module ActiveJob
109
109
  # end
110
110
  # end
111
111
  #
112
- # +:only+ and +:except+ options accepts Class, Array of Class or Proc. When passed a Proc,
112
+ # +:only+ and +:except+ options accept Class, Array of Class or Proc. When passed a Proc,
113
113
  # a hash containing the job's class and it's argument are passed as argument.
114
114
  #
115
115
  # Asserts the number of times a job is enqueued to a specific queue by passing +:queue+ option.
@@ -168,7 +168,7 @@ module ActiveJob
168
168
  # end
169
169
  # end
170
170
  #
171
- # +:only+ and +:except+ options accepts Class, Array of Class or Proc. When passed a Proc,
171
+ # +:only+ and +:except+ options accept Class, Array of Class or Proc. When passed a Proc,
172
172
  # a hash containing the job's class and it's argument are passed as argument.
173
173
  #
174
174
  # Asserts that no jobs are enqueued to a specific queue by passing +:queue+ option
@@ -325,7 +325,7 @@ module ActiveJob
325
325
  # end
326
326
  # end
327
327
  #
328
- # +:only+ and +:except+ options accepts Class, Array of Class or Proc. When passed a Proc,
328
+ # +:only+ and +:except+ options accept Class, Array of Class or Proc. When passed a Proc,
329
329
  # an instance of the job will be passed as argument.
330
330
  #
331
331
  # If the +:queue+ option is specified,
@@ -417,8 +417,20 @@ module ActiveJob
417
417
  end
418
418
  end
419
419
 
420
+ matching_class = potential_matches.select do |enqueued_job|
421
+ enqueued_job["job_class"] == job.to_s
422
+ end
423
+
420
424
  message = +"No enqueued job found with #{expected}"
421
- message << "\n\nPotential matches: #{potential_matches.join("\n")}" if potential_matches.present?
425
+ if potential_matches.empty?
426
+ message << "\n\nNo jobs were enqueued"
427
+ elsif matching_class.empty?
428
+ message << "\n\nNo jobs of class #{expected[:job]} were enqueued, job classes enqueued: "
429
+ message << potential_matches.map { |job| job["job_class"] }.join(", ")
430
+ else
431
+ message << "\n\nPotential matches: #{matching_class.join("\n")}"
432
+ end
433
+
422
434
  assert matching_job, message
423
435
  instantiate_job(matching_job)
424
436
  end
@@ -507,8 +519,20 @@ module ActiveJob
507
519
  end
508
520
  end
509
521
 
522
+ matching_class = potential_matches.select do |enqueued_job|
523
+ enqueued_job["job_class"] == job.to_s
524
+ end
525
+
510
526
  message = +"No performed job found with #{expected}"
511
- message << "\n\nPotential matches: #{potential_matches.join("\n")}" if potential_matches.present?
527
+ if potential_matches.empty?
528
+ message << "\n\nNo jobs were performed"
529
+ elsif matching_class.empty?
530
+ message << "\n\nNo jobs of class #{expected[:job]} were performed, job classes performed: "
531
+ message << potential_matches.map { |job| job["job_class"] }.join(", ")
532
+ else
533
+ message << "\n\nPotential matches: #{matching_class.join("\n")}"
534
+ end
535
+
512
536
  assert matching_job, message
513
537
 
514
538
  instantiate_job(matching_job)
@@ -555,7 +579,7 @@ module ActiveJob
555
579
  # assert_performed_jobs 1
556
580
  # end
557
581
  #
558
- # +:only+ and +:except+ options accepts Class, Array of Class or Proc. When passed a Proc,
582
+ # +:only+ and +:except+ options accept Class, Array of Class or Proc. When passed a Proc,
559
583
  # an instance of the job will be passed as argument.
560
584
  #
561
585
  # If the +:queue+ option is specified,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activejob
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0.alpha1
4
+ version: 7.0.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-15 00:00:00.000000000 Z
11
+ date: 2021-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 7.0.0.alpha1
19
+ version: 7.0.0.rc3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 7.0.0.alpha1
26
+ version: 7.0.0.rc3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: globalid
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -60,7 +60,6 @@ files:
60
60
  - lib/active_job/instrumentation.rb
61
61
  - lib/active_job/log_subscriber.rb
62
62
  - lib/active_job/logging.rb
63
- - lib/active_job/query_tags.rb
64
63
  - lib/active_job/queue_adapter.rb
65
64
  - lib/active_job/queue_adapters.rb
66
65
  - lib/active_job/queue_adapters/async_adapter.rb
@@ -101,11 +100,12 @@ licenses:
101
100
  - MIT
102
101
  metadata:
103
102
  bug_tracker_uri: https://github.com/rails/rails/issues
104
- changelog_uri: https://github.com/rails/rails/blob/v7.0.0.alpha1/activejob/CHANGELOG.md
105
- documentation_uri: https://api.rubyonrails.org/v7.0.0.alpha1/
103
+ changelog_uri: https://github.com/rails/rails/blob/v7.0.0.rc3/activejob/CHANGELOG.md
104
+ documentation_uri: https://api.rubyonrails.org/v7.0.0.rc3/
106
105
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
107
- source_code_uri: https://github.com/rails/rails/tree/v7.0.0.alpha1/activejob
108
- post_install_message:
106
+ source_code_uri: https://github.com/rails/rails/tree/v7.0.0.rc3/activejob
107
+ rubygems_mfa_required: 'true'
108
+ post_install_message:
109
109
  rdoc_options: []
110
110
  require_paths:
111
111
  - lib
@@ -120,8 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  - !ruby/object:Gem::Version
121
121
  version: 1.3.1
122
122
  requirements: []
123
- rubygems_version: 3.1.6
124
- signing_key:
123
+ rubygems_version: 3.2.15
124
+ signing_key:
125
125
  specification_version: 4
126
126
  summary: Job framework with pluggable queues.
127
127
  test_files: []
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveJob
4
- module QueryTags # :nodoc:
5
- extend ActiveSupport::Concern
6
-
7
- included do
8
- around_perform :expose_job_to_query_logs
9
- end
10
-
11
- private
12
- def expose_job_to_query_logs(&block)
13
- ActiveRecord::QueryLogs.set_context(job: self, &block)
14
- end
15
- end
16
- end