activejob 7.2.1.1 → 8.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -67
- data/lib/active_job/enqueue_after_transaction_commit.rb +18 -2
- data/lib/active_job/enqueuing.rb +3 -4
- data/lib/active_job/gem_version.rb +4 -4
- data/lib/active_job/log_subscriber.rb +8 -4
- data/lib/active_job/queue_adapter.rb +1 -0
- data/lib/active_job/queue_adapters/abstract_adapter.rb +0 -8
- data/lib/active_job/queue_adapters/async_adapter.rb +1 -1
- data/lib/active_job/queue_adapters/delayed_job_adapter.rb +0 -8
- data/lib/active_job/queue_adapters/inline_adapter.rb +0 -4
- data/lib/active_job/queue_adapters/queue_classic_adapter.rb +0 -8
- data/lib/active_job/queue_adapters/sucker_punch_adapter.rb +7 -0
- data/lib/active_job/queue_adapters/test_adapter.rb +1 -9
- data/lib/active_job/queue_adapters.rb +0 -3
- data/lib/active_job/railtie.rb +21 -3
- data/lib/active_job/serializers.rb +0 -2
- data/lib/active_job.rb +0 -12
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b057adb9e0f95a232c9e5f47426c2555738637e6ea540fa1e5ac420f16e3fcae
|
4
|
+
data.tar.gz: 0cfdb021f58ad66972c0399325444bca333d94cf1b41077052285ff1bb2b702a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5ccec22443249143387d8186b10065f403d4410bc042621b31aa128093ab34625a42c4f071e8752be0e6fb856258a490f3b855cb2a46a0edc187a4ae93a4745
|
7
|
+
data.tar.gz: 80192a27f0d1f8234686f2f1b8fbcc0e7bef144e38425d836958a38f3c00601dd4343bed0ef2edf82c21e0f215f1764452a651fbdd7100edb275aaeaa06a3c33
|
data/CHANGELOG.md
CHANGED
@@ -1,77 +1,20 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 8.0.0.rc1 (October 19, 2024) ##
|
2
2
|
|
3
|
-
*
|
4
|
-
|
5
|
-
|
6
|
-
## Rails 7.2.1 (August 22, 2024) ##
|
7
|
-
|
8
|
-
* No changes.
|
9
|
-
|
10
|
-
|
11
|
-
## Rails 7.2.0 (August 09, 2024) ##
|
12
|
-
|
13
|
-
* All tests now respect the `active_job.queue_adapter` config.
|
14
|
-
|
15
|
-
Previously if you had set `config.active_job.queue_adapter` in your `config/application.rb`
|
16
|
-
or `config/environments/test.rb` file, the adapter you selected was previously not used consistently
|
17
|
-
across all tests. In some tests your adapter would be used, but other tests would use the `TestAdapter`.
|
18
|
-
|
19
|
-
In Rails 7.2, all tests will respect the `queue_adapter` config if provided. If no config is provided,
|
20
|
-
the `TestAdapter` will continue to be used.
|
21
|
-
|
22
|
-
See [#48585](https://github.com/rails/rails/pull/48585) for more details.
|
23
|
-
|
24
|
-
*Alex Ghiculescu*
|
25
|
-
|
26
|
-
* Make Active Job transaction aware when used conjointly with Active Record.
|
27
|
-
|
28
|
-
A common mistake with Active Job is to enqueue jobs from inside a transaction,
|
29
|
-
causing them to potentially be picked and ran by another process, before the
|
30
|
-
transaction is committed, which may result in various errors.
|
31
|
-
|
32
|
-
```ruby
|
33
|
-
Topic.transaction do
|
34
|
-
topic = Topic.create(...)
|
35
|
-
NewTopicNotificationJob.perform_later(topic)
|
36
|
-
end
|
37
|
-
```
|
38
|
-
|
39
|
-
Now Active Job will automatically defer the enqueuing to after the transaction is committed,
|
40
|
-
and drop the job if the transaction is rolled back.
|
41
|
-
|
42
|
-
Various queue implementations can choose to disable this behavior, and users can disable it,
|
43
|
-
or force it on a per job basis:
|
44
|
-
|
45
|
-
```ruby
|
46
|
-
class NewTopicNotificationJob < ApplicationJob
|
47
|
-
self.enqueue_after_transaction_commit = :never # or `:always` or `:default`
|
48
|
-
end
|
49
|
-
```
|
50
|
-
|
51
|
-
*Jean Boussier*, *Cristian Bica*
|
52
|
-
|
53
|
-
* Do not trigger immediate loading of `ActiveJob::Base` when loading `ActiveJob::TestHelper`.
|
54
|
-
|
55
|
-
*Maxime Réty*
|
56
|
-
|
57
|
-
* Preserve the serialized timezone when deserializing `ActiveSupport::TimeWithZone` arguments.
|
58
|
-
|
59
|
-
*Joshua Young*
|
60
|
-
|
61
|
-
* Remove deprecated `:exponentially_longer` value for the `:wait` in `retry_on`.
|
3
|
+
* Remove deprecated `config.active_job.use_big_decimal_serializer`.
|
62
4
|
|
63
5
|
*Rafael Mendonça França*
|
64
6
|
|
65
|
-
* Remove deprecated support to set numeric values to `scheduled_at` attribute.
|
66
7
|
|
67
|
-
|
8
|
+
## Rails 8.0.0.beta1 (September 26, 2024) ##
|
68
9
|
|
69
|
-
* Deprecate `
|
10
|
+
* Deprecate `sucker_punch` as an adapter option.
|
70
11
|
|
71
|
-
|
12
|
+
If you're using this adapter, change to `adapter: async` for the same functionality.
|
72
13
|
|
73
|
-
*
|
14
|
+
*Dino Maric, zzak*
|
74
15
|
|
75
|
-
|
16
|
+
* Use `RAILS_MAX_THREADS` in `ActiveJob::AsyncAdapter`. If it is not set, use 5 as default.
|
17
|
+
|
18
|
+
*heka1024*
|
76
19
|
|
77
|
-
Please check [7-
|
20
|
+
Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/activejob/CHANGELOG.md) for previous changes.
|
@@ -4,13 +4,29 @@ module ActiveJob
|
|
4
4
|
module EnqueueAfterTransactionCommit # :nodoc:
|
5
5
|
private
|
6
6
|
def raw_enqueue
|
7
|
+
enqueue_after_transaction_commit = self.class.enqueue_after_transaction_commit
|
8
|
+
|
7
9
|
after_transaction = case self.class.enqueue_after_transaction_commit
|
8
10
|
when :always
|
11
|
+
ActiveJob.deprecator.warn(<<~MSG.squish)
|
12
|
+
Setting `#{self.class.name}.enqueue_after_transaction_commit = :always` is deprecated and will be removed in Rails 8.1.
|
13
|
+
Set to `true` to always enqueue the job after the transaction is committed.
|
14
|
+
MSG
|
9
15
|
true
|
10
16
|
when :never
|
17
|
+
ActiveJob.deprecator.warn(<<~MSG.squish)
|
18
|
+
Setting #{self.class.name}.enqueue_after_transaction_commit = :never` is deprecated and will be removed in Rails 8.1.
|
19
|
+
Set to `false` to never enqueue the job after the transaction is committed.
|
20
|
+
MSG
|
21
|
+
false
|
22
|
+
when :default
|
23
|
+
ActiveJob.deprecator.warn(<<~MSG.squish)
|
24
|
+
Setting `#{self.class.name}.enqueue_after_transaction_commit = :default` is deprecated and will be removed in Rails 8.1.
|
25
|
+
Set to `false` to never enqueue the job after the transaction is committed.
|
26
|
+
MSG
|
11
27
|
false
|
12
|
-
else
|
13
|
-
|
28
|
+
else
|
29
|
+
enqueue_after_transaction_commit
|
14
30
|
end
|
15
31
|
|
16
32
|
if after_transaction
|
data/lib/active_job/enqueuing.rb
CHANGED
@@ -48,10 +48,9 @@ module ActiveJob
|
|
48
48
|
# automatically defers the enqueue to after the transaction commits.
|
49
49
|
#
|
50
50
|
# It can be set on a per job basis:
|
51
|
-
# -
|
52
|
-
# -
|
53
|
-
|
54
|
-
class_attribute :enqueue_after_transaction_commit, instance_accessor: false, instance_predicate: false, default: :never
|
51
|
+
# - true forces the job to be deferred.
|
52
|
+
# - false forces the job to be queued immediately.
|
53
|
+
class_attribute :enqueue_after_transaction_commit, instance_accessor: false, instance_predicate: false, default: false
|
55
54
|
end
|
56
55
|
|
57
56
|
# Includes the +perform_later+ method for job initialization.
|
@@ -125,7 +125,7 @@ module ActiveJob
|
|
125
125
|
"Stopped retrying #{job.class} (Job ID: #{job.job_id}) due to a #{ex.class} (#{ex.message}), which reoccurred on #{job.executions} attempts."
|
126
126
|
end
|
127
127
|
end
|
128
|
-
subscribe_log_level :
|
128
|
+
subscribe_log_level :retry_stopped, :error
|
129
129
|
|
130
130
|
def discard(event)
|
131
131
|
job = event.payload[:job]
|
@@ -189,15 +189,19 @@ module ActiveJob
|
|
189
189
|
end
|
190
190
|
|
191
191
|
def log_enqueue_source
|
192
|
-
source =
|
192
|
+
source = enqueue_source_location
|
193
193
|
|
194
194
|
if source
|
195
195
|
logger.info("↳ #{source}")
|
196
196
|
end
|
197
197
|
end
|
198
198
|
|
199
|
-
def
|
200
|
-
|
199
|
+
def enqueue_source_location
|
200
|
+
Thread.each_caller_location do |location|
|
201
|
+
frame = backtrace_cleaner.clean_frame(location)
|
202
|
+
return frame if frame
|
203
|
+
end
|
204
|
+
nil
|
201
205
|
end
|
202
206
|
|
203
207
|
def enqueued_jobs_message(adapter, enqueued_jobs)
|
@@ -50,6 +50,7 @@ module ActiveJob
|
|
50
50
|
case name_or_adapter
|
51
51
|
when Symbol, String
|
52
52
|
queue_adapter = ActiveJob::QueueAdapters.lookup(name_or_adapter).new
|
53
|
+
queue_adapter.try(:check_adapter)
|
53
54
|
assign_adapter(name_or_adapter.to_s, queue_adapter)
|
54
55
|
else
|
55
56
|
if queue_adapter?(name_or_adapter)
|
@@ -7,14 +7,6 @@ module ActiveJob
|
|
7
7
|
# Active Job supports multiple job queue systems. ActiveJob::QueueAdapters::AbstractAdapter
|
8
8
|
# forms the abstraction layer which makes this possible.
|
9
9
|
class AbstractAdapter
|
10
|
-
# Defines whether enqueuing should happen implicitly to after commit when called
|
11
|
-
# from inside a transaction. Most adapters should return true, but some adapters
|
12
|
-
# that use the same database as Active Record and are transaction aware can return
|
13
|
-
# false to continue enqueuing jobs as part of the transaction.
|
14
|
-
def enqueue_after_transaction_commit?
|
15
|
-
true
|
16
|
-
end
|
17
|
-
|
18
10
|
def enqueue(job)
|
19
11
|
raise NotImplementedError
|
20
12
|
end
|
@@ -74,7 +74,7 @@ module ActiveJob
|
|
74
74
|
class Scheduler # :nodoc:
|
75
75
|
DEFAULT_EXECUTOR_OPTIONS = {
|
76
76
|
min_threads: 0,
|
77
|
-
max_threads:
|
77
|
+
max_threads: ENV.fetch("RAILS_MAX_THREADS", 5).to_i,
|
78
78
|
auto_terminate: true,
|
79
79
|
idletime: 60, # 1 minute
|
80
80
|
max_queue: 0, # unlimited
|
@@ -16,14 +16,6 @@ module ActiveJob
|
|
16
16
|
#
|
17
17
|
# Rails.application.config.active_job.queue_adapter = :delayed_job
|
18
18
|
class DelayedJobAdapter < AbstractAdapter
|
19
|
-
def initialize(enqueue_after_transaction_commit: false)
|
20
|
-
@enqueue_after_transaction_commit = enqueue_after_transaction_commit
|
21
|
-
end
|
22
|
-
|
23
|
-
def enqueue_after_transaction_commit? # :nodoc:
|
24
|
-
@enqueue_after_transaction_commit
|
25
|
-
end
|
26
|
-
|
27
19
|
def enqueue(job) # :nodoc:
|
28
20
|
delayed_job = Delayed::Job.enqueue(JobWrapper.new(job.serialize), queue: job.queue_name, priority: job.priority)
|
29
21
|
job.provider_job_id = delayed_job.id
|
@@ -11,10 +11,6 @@ module ActiveJob
|
|
11
11
|
#
|
12
12
|
# Rails.application.config.active_job.queue_adapter = :inline
|
13
13
|
class InlineAdapter < AbstractAdapter
|
14
|
-
def enqueue_after_transaction_commit? # :nodoc:
|
15
|
-
false
|
16
|
-
end
|
17
|
-
|
18
14
|
def enqueue(job) # :nodoc:
|
19
15
|
Base.execute(job.serialize)
|
20
16
|
end
|
@@ -19,14 +19,6 @@ module ActiveJob
|
|
19
19
|
#
|
20
20
|
# Rails.application.config.active_job.queue_adapter = :queue_classic
|
21
21
|
class QueueClassicAdapter < AbstractAdapter
|
22
|
-
def initialize(enqueue_after_transaction_commit: false)
|
23
|
-
@enqueue_after_transaction_commit = enqueue_after_transaction_commit
|
24
|
-
end
|
25
|
-
|
26
|
-
def enqueue_after_transaction_commit? # :nodoc:
|
27
|
-
@enqueue_after_transaction_commit
|
28
|
-
end
|
29
|
-
|
30
22
|
def enqueue(job) # :nodoc:
|
31
23
|
qc_job = build_queue(job.queue_name).enqueue("#{JobWrapper.name}.perform", job.serialize)
|
32
24
|
job.provider_job_id = qc_job["id"] if qc_job.is_a?(Hash)
|
@@ -18,6 +18,13 @@ module ActiveJob
|
|
18
18
|
#
|
19
19
|
# Rails.application.config.active_job.queue_adapter = :sucker_punch
|
20
20
|
class SuckerPunchAdapter < AbstractAdapter
|
21
|
+
def check_adapter
|
22
|
+
ActiveJob.deprecator.warn <<~MSG.squish
|
23
|
+
The `sucker_punch` adapter is deprecated and will be removed in Rails 8.1.
|
24
|
+
Please use the `async` adapter instead.
|
25
|
+
MSG
|
26
|
+
end
|
27
|
+
|
21
28
|
def enqueue(job) # :nodoc:
|
22
29
|
if JobWrapper.respond_to?(:perform_async)
|
23
30
|
# sucker_punch 2.0 API
|
@@ -12,17 +12,9 @@ module ActiveJob
|
|
12
12
|
#
|
13
13
|
# Rails.application.config.active_job.queue_adapter = :test
|
14
14
|
class TestAdapter < AbstractAdapter
|
15
|
-
attr_accessor(:perform_enqueued_jobs, :perform_enqueued_at_jobs, :filter, :reject, :queue, :at
|
15
|
+
attr_accessor(:perform_enqueued_jobs, :perform_enqueued_at_jobs, :filter, :reject, :queue, :at)
|
16
16
|
attr_writer(:enqueued_jobs, :performed_jobs)
|
17
17
|
|
18
|
-
def initialize(enqueue_after_transaction_commit: true)
|
19
|
-
@enqueue_after_transaction_commit = enqueue_after_transaction_commit
|
20
|
-
end
|
21
|
-
|
22
|
-
def enqueue_after_transaction_commit? # :nodoc:
|
23
|
-
@enqueue_after_transaction_commit
|
24
|
-
end
|
25
|
-
|
26
18
|
# Provides a store of all the enqueued jobs with the TestAdapter so you can check them.
|
27
19
|
def enqueued_jobs
|
28
20
|
@enqueued_jobs ||= []
|
@@ -12,7 +12,6 @@ module ActiveJob
|
|
12
12
|
# * {Resque}[https://github.com/resque/resque]
|
13
13
|
# * {Sidekiq}[https://sidekiq.org]
|
14
14
|
# * {Sneakers}[https://github.com/jondot/sneakers]
|
15
|
-
# * {Sucker Punch}[https://github.com/brandonhilkert/sucker_punch]
|
16
15
|
# * Please Note: We are not accepting pull requests for new adapters. See the {README}[link:files/activejob/README_md.html] for more details.
|
17
16
|
#
|
18
17
|
# For testing and development Active Job has three built-in adapters:
|
@@ -32,7 +31,6 @@ module ActiveJob
|
|
32
31
|
# | Resque | Yes | Yes | Yes (Gem) | Queue | Global | Yes |
|
33
32
|
# | Sidekiq | Yes | Yes | Yes | Queue | No | Job |
|
34
33
|
# | Sneakers | Yes | Yes | No | Queue | Queue | No |
|
35
|
-
# | Sucker Punch | Yes | Yes | Yes | No | No | No |
|
36
34
|
# | Active Job Async | Yes | Yes | Yes | No | No | No |
|
37
35
|
# | Active Job Inline | No | Yes | N/A | N/A | N/A | N/A |
|
38
36
|
# | Active Job Test | No | Yes | N/A | N/A | N/A | N/A |
|
@@ -119,7 +117,6 @@ module ActiveJob
|
|
119
117
|
autoload :InlineAdapter
|
120
118
|
autoload :BackburnerAdapter
|
121
119
|
autoload :DelayedJobAdapter
|
122
|
-
autoload :QueAdapter
|
123
120
|
autoload :QueueClassicAdapter
|
124
121
|
autoload :ResqueAdapter
|
125
122
|
autoload :SidekiqAdapter
|
data/lib/active_job/railtie.rb
CHANGED
@@ -31,7 +31,22 @@ module ActiveJob
|
|
31
31
|
ActiveJob::Base.include EnqueueAfterTransactionCommit
|
32
32
|
|
33
33
|
if app.config.active_job.key?(:enqueue_after_transaction_commit)
|
34
|
-
ActiveJob
|
34
|
+
ActiveJob.deprecator.warn(<<~MSG.squish)
|
35
|
+
`config.active_job.enqueue_after_transaction_commit` is deprecated and will be removed in Rails 8.1.
|
36
|
+
This configuration can still be set on individual jobs using `self.enqueue_after_transaction_commit=`,
|
37
|
+
but due the nature of this behavior, it is not recommended to be set globally.
|
38
|
+
MSG
|
39
|
+
|
40
|
+
value = case app.config.active_job.enqueue_after_transaction_commit
|
41
|
+
when :always
|
42
|
+
true
|
43
|
+
when :never
|
44
|
+
false
|
45
|
+
else
|
46
|
+
false
|
47
|
+
end
|
48
|
+
|
49
|
+
ActiveJob::Base.enqueue_after_transaction_commit = value
|
35
50
|
end
|
36
51
|
end
|
37
52
|
end
|
@@ -54,7 +69,8 @@ module ActiveJob
|
|
54
69
|
# Configs used in other initializers
|
55
70
|
options = options.except(
|
56
71
|
:log_query_tags_around_perform,
|
57
|
-
:custom_serializers
|
72
|
+
:custom_serializers,
|
73
|
+
:enqueue_after_transaction_commit
|
58
74
|
)
|
59
75
|
|
60
76
|
options.each do |k, v|
|
@@ -91,7 +107,9 @@ module ActiveJob
|
|
91
107
|
app.config.active_record.query_log_tags |= [:job]
|
92
108
|
|
93
109
|
ActiveSupport.on_load(:active_record) do
|
94
|
-
ActiveRecord::QueryLogs.taggings
|
110
|
+
ActiveRecord::QueryLogs.taggings = ActiveRecord::QueryLogs.taggings.merge(
|
111
|
+
job: ->(context) { context[:job].class.name if context[:job] }
|
112
|
+
)
|
95
113
|
end
|
96
114
|
end
|
97
115
|
end
|
data/lib/active_job.rb
CHANGED
@@ -49,18 +49,6 @@ module ActiveJob
|
|
49
49
|
autoload :TestCase
|
50
50
|
autoload :TestHelper
|
51
51
|
|
52
|
-
def self.use_big_decimal_serializer
|
53
|
-
ActiveJob.deprecator.warn <<-WARNING.squish
|
54
|
-
Rails.application.config.active_job.use_big_decimal_serializer is deprecated and will be removed in Rails 8.0.
|
55
|
-
WARNING
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.use_big_decimal_serializer=(value)
|
59
|
-
ActiveJob.deprecator.warn <<-WARNING.squish
|
60
|
-
Rails.application.config.active_job.use_big_decimal_serializer is deprecated and will be removed in Rails 8.0.
|
61
|
-
WARNING
|
62
|
-
end
|
63
|
-
|
64
52
|
##
|
65
53
|
# :singleton-method: verbose_enqueue_logs
|
66
54
|
#
|
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:
|
4
|
+
version: 8.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: 2024-10-
|
11
|
+
date: 2024-10-19 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:
|
19
|
+
version: 8.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:
|
26
|
+
version: 8.0.0.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: globalid
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,10 +104,10 @@ licenses:
|
|
104
104
|
- MIT
|
105
105
|
metadata:
|
106
106
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
107
|
-
changelog_uri: https://github.com/rails/rails/blob/
|
108
|
-
documentation_uri: https://api.rubyonrails.org/
|
107
|
+
changelog_uri: https://github.com/rails/rails/blob/v8.0.0.rc1/activejob/CHANGELOG.md
|
108
|
+
documentation_uri: https://api.rubyonrails.org/v8.0.0.rc1/
|
109
109
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
110
|
-
source_code_uri: https://github.com/rails/rails/tree/
|
110
|
+
source_code_uri: https://github.com/rails/rails/tree/v8.0.0.rc1/activejob
|
111
111
|
rubygems_mfa_required: 'true'
|
112
112
|
post_install_message:
|
113
113
|
rdoc_options: []
|
@@ -117,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
117
|
requirements:
|
118
118
|
- - ">="
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version: 3.
|
120
|
+
version: 3.2.0
|
121
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
123
|
- - ">="
|