activejob 7.0.0.alpha2 → 7.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/lib/active_job/callbacks.rb +3 -28
- data/lib/active_job/configured_job.rb +1 -1
- data/lib/active_job/core.rb +10 -0
- data/lib/active_job/enqueuing.rb +1 -4
- data/lib/active_job/execution.rb +1 -0
- data/lib/active_job/gem_version.rb +1 -1
- data/lib/active_job/railtie.rb +1 -5
- data/lib/active_job/serializers/module_serializer.rb +1 -0
- data/lib/active_job/test_helper.rb +30 -6
- metadata +9 -9
- data/lib/active_job/query_tags.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ae9afbd809eb16b45a08dd01c5a4b380bc0ce41055e074c0156ca1f0fae2650
|
4
|
+
data.tar.gz: 87653df366fcb02cead16d16a256fb99292cdce5f5a5504ceb2efe205378ca4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07b924bedc982b2c43b7f0a75bdb3a9f0770730a17cb4c26a1dd553923ac2bcf5f9b186279e0d11d36975d3d128df27caaa1e3ca8d225a472c70b7fccbbfd219
|
7
|
+
data.tar.gz: 3bff03b822d41e5a88bf1e73273e09fa06f2ac311e508d1c99bfb72d852980beffed30e24b0cfdd1fa8fce9a05dd04b0ef108fb9ef9c66fe67fbfe0dda206475
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
* Remove deprecated `:return_false_on_aborted_enqueue` option.
|
2
|
+
|
3
|
+
*Rafael Mendonça França*
|
4
|
+
|
5
|
+
* Deprecated `Rails.config.active_job.skip_after_callbacks_if_terminated`.
|
6
|
+
|
7
|
+
*Rafael Mendonça França*
|
8
|
+
|
9
|
+
* Removed deprecated behavior that was not halting `after_enqueue`/`after_perform` callbacks when a
|
10
|
+
previous callback was halted with `throw :abort`.
|
11
|
+
|
12
|
+
*Rafael Mendonça França*
|
13
|
+
|
14
|
+
* Raise an `SerializationError` in `Serializer::ModuleSerializer`
|
15
|
+
if the module name is not present.
|
16
|
+
|
17
|
+
*Veerpal Brar*
|
18
|
+
|
19
|
+
|
1
20
|
## Rails 7.0.0.alpha2 (September 15, 2021) ##
|
2
21
|
|
3
22
|
* No changes.
|
data/lib/active_job/callbacks.rb
CHANGED
@@ -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
|
-
|
37
|
-
|
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
|
data/lib/active_job/core.rb
CHANGED
@@ -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?
|
data/lib/active_job/enqueuing.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/active_job/execution.rb
CHANGED
data/lib/active_job/railtie.rb
CHANGED
@@ -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
|
69
|
+
ActiveRecord::QueryLogs.taggings[:job] = ->(context) { context[:job].class.name if context[:job] }
|
74
70
|
end
|
75
71
|
end
|
76
72
|
end
|
@@ -109,7 +109,7 @@ module ActiveJob
|
|
109
109
|
# end
|
110
110
|
# end
|
111
111
|
#
|
112
|
-
# +:only+ and +:except+ options
|
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
|
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
|
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
|
-
|
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
|
-
|
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
|
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.
|
4
|
+
version: 7.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-06 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.
|
19
|
+
version: 7.0.0.rc1
|
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.
|
26
|
+
version: 7.0.0.rc1
|
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,10 +100,11 @@ 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.
|
105
|
-
documentation_uri: https://api.rubyonrails.org/v7.0.0.
|
103
|
+
changelog_uri: https://github.com/rails/rails/blob/v7.0.0.rc1/activejob/CHANGELOG.md
|
104
|
+
documentation_uri: https://api.rubyonrails.org/v7.0.0.rc1/
|
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.
|
106
|
+
source_code_uri: https://github.com/rails/rails/tree/v7.0.0.rc1/activejob
|
107
|
+
rubygems_mfa_required: 'true'
|
108
108
|
post_install_message:
|
109
109
|
rdoc_options: []
|
110
110
|
require_paths:
|
@@ -120,7 +120,7 @@ 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.
|
123
|
+
rubygems_version: 3.2.22
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Job framework with pluggable queues.
|
@@ -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
|