activejob 7.1.5.2 → 8.1.2.1
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 +86 -264
- data/README.md +8 -6
- data/lib/active_job/arguments.rb +51 -59
- data/lib/active_job/base.rb +5 -6
- data/lib/active_job/callbacks.rb +0 -3
- data/lib/active_job/configured_job.rb +5 -4
- data/lib/active_job/continuable.rb +102 -0
- data/lib/active_job/continuation/step.rb +83 -0
- data/lib/active_job/continuation/test_helper.rb +89 -0
- data/lib/active_job/continuation/validation.rb +50 -0
- data/lib/active_job/continuation.rb +332 -0
- data/lib/active_job/core.rb +25 -22
- data/lib/active_job/enqueue_after_transaction_commit.rb +38 -0
- data/lib/active_job/enqueuing.rb +46 -12
- data/lib/active_job/exceptions.rb +21 -17
- data/lib/active_job/execution_state.rb +11 -0
- data/lib/active_job/gem_version.rb +3 -3
- data/lib/active_job/instrumentation.rb +12 -12
- data/lib/active_job/log_subscriber.rb +65 -6
- data/lib/active_job/logging.rb +16 -2
- data/lib/active_job/queue_adapter.rb +6 -4
- data/lib/active_job/queue_adapters/abstract_adapter.rb +25 -0
- data/lib/active_job/queue_adapters/async_adapter.rb +7 -3
- data/lib/active_job/queue_adapters/backburner_adapter.rb +1 -1
- data/lib/active_job/queue_adapters/delayed_job_adapter.rb +1 -1
- data/lib/active_job/queue_adapters/inline_adapter.rb +1 -1
- data/lib/active_job/queue_adapters/queue_classic_adapter.rb +1 -1
- data/lib/active_job/queue_adapters/resque_adapter.rb +1 -1
- data/lib/active_job/queue_adapters/sidekiq_adapter.rb +20 -1
- data/lib/active_job/queue_adapters/sneakers_adapter.rb +1 -1
- data/lib/active_job/queue_adapters/test_adapter.rb +6 -2
- data/lib/active_job/queue_adapters.rb +1 -4
- data/lib/active_job/railtie.rb +25 -4
- data/lib/active_job/serializers/action_controller_parameters_serializer.rb +25 -0
- data/lib/active_job/serializers/big_decimal_serializer.rb +3 -4
- data/lib/active_job/serializers/date_serializer.rb +3 -4
- data/lib/active_job/serializers/date_time_serializer.rb +3 -4
- data/lib/active_job/serializers/duration_serializer.rb +5 -6
- data/lib/active_job/serializers/module_serializer.rb +3 -4
- data/lib/active_job/serializers/object_serializer.rb +13 -14
- data/lib/active_job/serializers/range_serializer.rb +9 -9
- data/lib/active_job/serializers/symbol_serializer.rb +4 -5
- data/lib/active_job/serializers/time_serializer.rb +3 -4
- data/lib/active_job/serializers/time_with_zone_serializer.rb +3 -4
- data/lib/active_job/serializers.rb +62 -18
- data/lib/active_job/structured_event_subscriber.rb +220 -0
- data/lib/active_job/test_helper.rb +28 -5
- data/lib/active_job.rb +5 -9
- metadata +18 -11
- data/lib/active_job/queue_adapters/sucker_punch_adapter.rb +0 -49
- data/lib/active_job/timezones.rb +0 -13
- data/lib/active_job/translation.rb +0 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4fb3974d90bc3c3175e963a1739f374bc4fad4f8b78894cb4516ebb2c5e9dab4
|
|
4
|
+
data.tar.gz: 4442e7956e198f0517ea33a69cf23206fa415ce5b4f4a5ba048cf36ca908b753
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7cbbf37e5786cb6f04f3d44231b97c2fdaa35d4a91a99659ab3b532547448b454dfc998a2f6b8fa986422da93d4fbafa7adf616d6883af129ee73a0653cc7caf
|
|
7
|
+
data.tar.gz: f1a76bd6fe157435b4736dee13e6c72f819e144406a91e9084d295a3a4ea38cc41e672b57455fa35cd552025dd11f26176a29207a1baff78d37701ec07fc3706
|
data/CHANGELOG.md
CHANGED
|
@@ -1,315 +1,137 @@
|
|
|
1
|
-
## Rails
|
|
1
|
+
## Rails 8.1.2.1 (March 23, 2026) ##
|
|
2
2
|
|
|
3
3
|
* No changes.
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
## Rails
|
|
6
|
+
## Rails 8.1.2 (January 08, 2026) ##
|
|
7
7
|
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Rails 7.1.5 (October 30, 2024) ##
|
|
12
|
-
|
|
13
|
-
* No changes.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
## Rails 7.1.4.2 (October 23, 2024) ##
|
|
17
|
-
|
|
18
|
-
* No changes.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
## Rails 7.1.4.1 (October 15, 2024) ##
|
|
22
|
-
|
|
23
|
-
* No changes.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
## Rails 7.1.4 (August 22, 2024) ##
|
|
8
|
+
* Fix `ActiveJob.perform_all_later` to respect `job_class.enqueue_after_transaction_commit`.
|
|
27
9
|
|
|
28
|
-
|
|
10
|
+
Previously, `perform_all_later` would enqueue all jobs immediately, even if
|
|
11
|
+
they had `enqueue_after_transaction_commit = true`. Now it correctly defers
|
|
12
|
+
jobs with this setting until after transaction commits, matching the behavior
|
|
13
|
+
of `perform_later`.
|
|
29
14
|
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
## Rails 7.1.3.4 (June 04, 2024) ##
|
|
34
|
-
|
|
35
|
-
* No changes.
|
|
15
|
+
*OuYangJinTing*
|
|
36
16
|
|
|
17
|
+
* Fix using custom serializers with `ActiveJob::Arguments.serialize` when
|
|
18
|
+
`ActiveJob::Base` hasn't been loaded.
|
|
37
19
|
|
|
38
|
-
|
|
20
|
+
*Hartley McGuire*
|
|
39
21
|
|
|
40
|
-
|
|
22
|
+
## Rails 8.1.1 (October 28, 2025) ##
|
|
41
23
|
|
|
24
|
+
* Only index new serializers.
|
|
42
25
|
|
|
43
|
-
|
|
26
|
+
*Jesse Sharps*
|
|
44
27
|
|
|
45
|
-
* No changes.
|
|
46
28
|
|
|
29
|
+
## Rails 8.1.0 (October 22, 2025) ##
|
|
47
30
|
|
|
48
|
-
|
|
31
|
+
* Add structured events for Active Job:
|
|
32
|
+
- `active_job.enqueued`
|
|
33
|
+
- `active_job.bulk_enqueued`
|
|
34
|
+
- `active_job.started`
|
|
35
|
+
- `active_job.completed`
|
|
36
|
+
- `active_job.retry_scheduled`
|
|
37
|
+
- `active_job.retry_stopped`
|
|
38
|
+
- `active_job.discarded`
|
|
39
|
+
- `active_job.interrupt`
|
|
40
|
+
- `active_job.resume`
|
|
41
|
+
- `active_job.step_skipped`
|
|
42
|
+
- `active_job.step_started`
|
|
43
|
+
- `active_job.step`
|
|
49
44
|
|
|
50
|
-
*
|
|
45
|
+
*Adrianna Chang*
|
|
51
46
|
|
|
47
|
+
* Deprecate built-in `sidekiq` adapter.
|
|
52
48
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
* Do not trigger immediate loading of `ActiveJob::Base` when loading `ActiveJob::TestHelper`.
|
|
56
|
-
|
|
57
|
-
*Maxime Réty*
|
|
58
|
-
|
|
59
|
-
* Preserve the serialized timezone when deserializing `ActiveSupport::TimeWithZone` arguments.
|
|
60
|
-
|
|
61
|
-
*Joshua Young*
|
|
62
|
-
|
|
63
|
-
* Fix ActiveJob arguments serialization to correctly serialize String subclasses having custom serializers.
|
|
49
|
+
If you're using this adapter, upgrade to `sidekiq` 7.3.3 or later to use the `sidekiq` gem's adapter.
|
|
64
50
|
|
|
65
51
|
*fatkodima*
|
|
66
52
|
|
|
67
|
-
|
|
68
|
-
## Rails 7.1.2 (November 10, 2023) ##
|
|
69
|
-
|
|
70
|
-
* No changes.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
## Rails 7.1.1 (October 11, 2023) ##
|
|
74
|
-
|
|
75
|
-
* Don't log enqueuing details when the job wasn't enqueued.
|
|
76
|
-
|
|
77
|
-
*Dustin Brown*
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
## Rails 7.1.0 (October 05, 2023) ##
|
|
81
|
-
|
|
82
|
-
* No changes.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
## Rails 7.1.0.rc2 (October 01, 2023) ##
|
|
86
|
-
|
|
87
|
-
* Make sure `scheduled_at` is a Time object when asserting enqueued jobs.
|
|
53
|
+
* Remove deprecated internal `SuckerPunch` adapter in favor of the adapter included with the `sucker_punch` gem.
|
|
88
54
|
|
|
89
55
|
*Rafael Mendonça França*
|
|
90
56
|
|
|
57
|
+
* Remove support to set `ActiveJob::Base.enqueue_after_transaction_commit` to `:never`, `:always` and `:default`.
|
|
91
58
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
* Set `scheduled_at` attribute as a Time object instead of epoch seconds, and serialize and deserialize the value
|
|
95
|
-
when enqueued. Assigning a numeric/epoch value to scheduled_at= is deprecated; use a Time object instead.
|
|
96
|
-
|
|
97
|
-
Deserializes `enqueued_at` as a Time instead of ISO8601 String.
|
|
98
|
-
|
|
99
|
-
*Ben Sheldon*
|
|
100
|
-
|
|
101
|
-
* Clarify the backoff strategy for the recommended `:wait` option when retrying jobs
|
|
102
|
-
|
|
103
|
-
`wait: :exponentially_longer` is waiting polynomially longer, so it is now recommended to use `wait: :polynomially_longer` to keep the same behavior.
|
|
59
|
+
*Rafael Mendonça França*
|
|
104
60
|
|
|
105
|
-
|
|
61
|
+
* Remove deprecated `Rails.application.config.active_job.enqueue_after_transaction_commit`.
|
|
106
62
|
|
|
63
|
+
*Rafael Mendonça França*
|
|
107
64
|
|
|
108
|
-
|
|
65
|
+
* `ActiveJob::Serializers::ObjectSerializers#klass` method is now public.
|
|
109
66
|
|
|
110
|
-
|
|
111
|
-
|
|
67
|
+
Custom Active Job serializers must have a public `#klass` method too.
|
|
68
|
+
The returned class will be index allowing for faster serialization.
|
|
112
69
|
|
|
113
|
-
*
|
|
70
|
+
*Jean Boussier*
|
|
114
71
|
|
|
115
|
-
*
|
|
72
|
+
* Allow jobs to the interrupted and resumed with Continuations
|
|
116
73
|
|
|
117
|
-
|
|
74
|
+
A job can use Continuations by including the `ActiveJob::Continuable`
|
|
75
|
+
concern. Continuations split jobs into steps. When the queuing system
|
|
76
|
+
is shutting down jobs can be interrupted and their progress saved.
|
|
118
77
|
|
|
119
78
|
```ruby
|
|
120
|
-
class
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
79
|
+
class ProcessImportJob
|
|
80
|
+
include ActiveJob::Continuable
|
|
81
|
+
|
|
82
|
+
def perform(import_id)
|
|
83
|
+
@import = Import.find(import_id)
|
|
84
|
+
|
|
85
|
+
# block format
|
|
86
|
+
step :initialize do
|
|
87
|
+
@import.initialize
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# step with cursor, the cursor is saved when the job is interrupted
|
|
91
|
+
step :process do |step|
|
|
92
|
+
@import.records.find_each(start: step.cursor) do |record|
|
|
93
|
+
record.process
|
|
94
|
+
step.advance! from: record.id
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# method format
|
|
99
|
+
step :finalize
|
|
100
|
+
|
|
101
|
+
private
|
|
102
|
+
def finalize
|
|
103
|
+
@import.finalize
|
|
104
|
+
end
|
|
127
105
|
end
|
|
128
106
|
end
|
|
129
107
|
```
|
|
130
108
|
|
|
131
|
-
|
|
132
|
-
still be raised after the block has been run.
|
|
133
|
-
|
|
134
|
-
*Rob Cardy*
|
|
109
|
+
*Donal McBreen*
|
|
135
110
|
|
|
136
|
-
*
|
|
111
|
+
* Defer invocation of ActiveJob enqueue callbacks until after commit when
|
|
112
|
+
`enqueue_after_transaction_commit` is enabled.
|
|
137
113
|
|
|
138
|
-
|
|
139
|
-
It will now return a hash just like a regular Duration.
|
|
114
|
+
*Will Roever*
|
|
140
115
|
|
|
141
|
-
|
|
142
|
-
(eg `duration + 1.year`).
|
|
116
|
+
* Add `report:` option to `ActiveJob::Base#retry_on` and `#discard_on`
|
|
143
117
|
|
|
144
|
-
|
|
118
|
+
When the `report:` option is passed, errors will be reported to the error reporter
|
|
119
|
+
before being retried / discarded.
|
|
145
120
|
|
|
146
|
-
*
|
|
121
|
+
*Andrew Novoselac*
|
|
147
122
|
|
|
148
|
-
|
|
149
|
-
will work correctly even if the test adapter is not used.
|
|
123
|
+
* Accept a block for `ActiveJob::ConfiguredJob#perform_later`.
|
|
150
124
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
* Allow queue adapters to provide a custom name by implementing `queue_adapter_name`
|
|
154
|
-
|
|
155
|
-
*Sander Verdonschot*
|
|
156
|
-
|
|
157
|
-
* Log background job enqueue callers
|
|
158
|
-
|
|
159
|
-
Add `verbose_enqueue_logs` configuration option to display the caller
|
|
160
|
-
of background job enqueue in the log to help with debugging.
|
|
161
|
-
|
|
162
|
-
Example log line:
|
|
163
|
-
|
|
164
|
-
```
|
|
165
|
-
Enqueued AvatarThumbnailsJob (Job ID: ab528951-41fb-4c48-9129-3171791c27d6) to Sidekiq(default) with arguments: 1092412064
|
|
166
|
-
↳ app/models/user.rb:421:in `generate_avatar_thumbnails'
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
Enabled in development only for new and upgraded applications. Not recommended for use
|
|
170
|
-
in the production environment since it relies on Ruby's `Kernel#caller` which is fairly slow.
|
|
125
|
+
This was inconsistent with a regular `ActiveJob::Base#perform_later`.
|
|
171
126
|
|
|
172
127
|
*fatkodima*
|
|
173
128
|
|
|
174
|
-
*
|
|
175
|
-
|
|
176
|
-
*Cameron Matheson*
|
|
177
|
-
|
|
178
|
-
* Add `perform_all_later` to enqueue multiple jobs at once
|
|
179
|
-
|
|
180
|
-
This adds the ability to bulk enqueue jobs, without running callbacks, by
|
|
181
|
-
passing multiple jobs or an array of jobs. For example:
|
|
182
|
-
|
|
183
|
-
```ruby
|
|
184
|
-
ActiveJob.perform_all_later(MyJob.new("hello", 42), MyJob.new("world", 0))
|
|
185
|
-
|
|
186
|
-
user_jobs = User.pluck(:id).map { |id| UserJob.new(user_id: id) }
|
|
187
|
-
ActiveJob.perform_all_later(user_jobs)
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
This can greatly reduce the number of round-trips to the queue datastore.
|
|
191
|
-
For queue adapters that do not implement the new `enqueue_all` method, we
|
|
192
|
-
fall back to enqueuing jobs individually. The Sidekiq adapter implements
|
|
193
|
-
`enqueue_all` with `push_bulk`.
|
|
194
|
-
|
|
195
|
-
This method does not use the existing `enqueue.active_job` event, but adds a
|
|
196
|
-
new event `enqueue_all.active_job`.
|
|
197
|
-
|
|
198
|
-
*Sander Verdonschot*
|
|
199
|
-
|
|
200
|
-
* Don't double log the `job` when using `ActiveRecord::QueryLog`
|
|
201
|
-
|
|
202
|
-
Previously if you set `config.active_record.query_log_tags` to an array that included
|
|
203
|
-
`:job`, the job name would get logged twice. This bug has been fixed.
|
|
204
|
-
|
|
205
|
-
*Alex Ghiculescu*
|
|
206
|
-
|
|
207
|
-
* Add support for Sidekiq's transaction-aware client
|
|
208
|
-
|
|
209
|
-
*Jonathan del Strother*
|
|
210
|
-
|
|
211
|
-
* Remove QueAdapter from Active Job.
|
|
212
|
-
|
|
213
|
-
After maintaining Active Job QueAdapter by Rails and Que side
|
|
214
|
-
to support Ruby 3 keyword arguments and options provided as top level keywords,
|
|
215
|
-
it is quite difficult to maintain it this way.
|
|
216
|
-
|
|
217
|
-
Active Job Que adapter can be included in the future version of que gem itself.
|
|
218
|
-
|
|
219
|
-
*Yasuo Honda*
|
|
220
|
-
|
|
221
|
-
* Fix BigDecimal (de)serialization for adapters using JSON.
|
|
222
|
-
|
|
223
|
-
Previously, BigDecimal was listed as not needing a serializer. However,
|
|
224
|
-
when used with an adapter storing the job arguments as JSON, it would get
|
|
225
|
-
serialized as a simple String, resulting in deserialization also producing
|
|
226
|
-
a String (instead of a BigDecimal).
|
|
227
|
-
|
|
228
|
-
By using a serializer, we ensure the round trip is safe.
|
|
229
|
-
|
|
230
|
-
To ensure applications using BigDecimal job arguments are not subject to
|
|
231
|
-
race conditions during deployment (where a replica running a version of
|
|
232
|
-
Rails without BigDecimalSerializer fails to deserialize an argument
|
|
233
|
-
serialized with it), `ActiveJob.use_big_decimal_serializer` is disabled by
|
|
234
|
-
default, and can be set to true in a following deployment..
|
|
235
|
-
|
|
236
|
-
*Sam Bostock*
|
|
237
|
-
|
|
238
|
-
* Preserve full-precision `enqueued_at` timestamps for serialized jobs,
|
|
239
|
-
allowing more accurate reporting of how long a job spent waiting in the
|
|
240
|
-
queue before it was performed.
|
|
241
|
-
|
|
242
|
-
Retains IS08601 format compatibility.
|
|
243
|
-
|
|
244
|
-
*Jeremy Daer*
|
|
245
|
-
|
|
246
|
-
* Add `--parent` option to job generator to specify parent class of job.
|
|
129
|
+
* Raise a more specific error during deserialization when a previously serialized job class is now unknown.
|
|
247
130
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
```ruby
|
|
253
|
-
class ProcessPaymentJob < PaymentJob
|
|
254
|
-
# ...
|
|
255
|
-
end
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
*Gannon McGibbon*
|
|
259
|
-
|
|
260
|
-
* Add more detailed description to job generator.
|
|
261
|
-
|
|
262
|
-
*Gannon McGibbon*
|
|
263
|
-
|
|
264
|
-
* `perform.active_job` notification payloads now include `:db_runtime`, which
|
|
265
|
-
is the total time (in ms) taken by database queries while performing a job.
|
|
266
|
-
This value can be used to better understand how a job's time is spent.
|
|
267
|
-
|
|
268
|
-
*Jonathan Hefner*
|
|
269
|
-
|
|
270
|
-
* Update `ActiveJob::QueueAdapters::QueAdapter` to remove deprecation warning.
|
|
271
|
-
|
|
272
|
-
Remove a deprecation warning introduced in que 1.2 to prepare for changes in
|
|
273
|
-
que 2.0 necessary for Ruby 3 compatibility.
|
|
274
|
-
|
|
275
|
-
*Damir Zekic* and *Adis Hasovic*
|
|
276
|
-
|
|
277
|
-
* Add missing `bigdecimal` require in `ActiveJob::Arguments`
|
|
278
|
-
|
|
279
|
-
Could cause `uninitialized constant ActiveJob::Arguments::BigDecimal (NameError)`
|
|
280
|
-
when loading Active Job in isolation.
|
|
281
|
-
|
|
282
|
-
*Jean Boussier*
|
|
283
|
-
|
|
284
|
-
* Allow testing `discard_on/retry_on ActiveJob::DeserializationError`
|
|
285
|
-
|
|
286
|
-
Previously in `perform_enqueued_jobs`, `deserialize_arguments_if_needed`
|
|
287
|
-
was called before calling `perform_now`. When a record no longer exists
|
|
288
|
-
and is serialized using GlobalID this led to raising
|
|
289
|
-
an `ActiveJob::DeserializationError` before reaching `perform_now` call.
|
|
290
|
-
This behavior makes difficult testing the job `discard_on/retry_on` logic.
|
|
291
|
-
|
|
292
|
-
Now `deserialize_arguments_if_needed` call is postponed to when `perform_now`
|
|
293
|
-
is called.
|
|
294
|
-
|
|
295
|
-
Example:
|
|
296
|
-
|
|
297
|
-
```ruby
|
|
298
|
-
class UpdateUserJob < ActiveJob::Base
|
|
299
|
-
discard_on ActiveJob::DeserializationError
|
|
300
|
-
|
|
301
|
-
def perform(user)
|
|
302
|
-
# ...
|
|
303
|
-
end
|
|
304
|
-
end
|
|
305
|
-
|
|
306
|
-
# In the test
|
|
307
|
-
User.destroy_all
|
|
308
|
-
assert_nothing_raised do
|
|
309
|
-
perform_enqueued_jobs only: UpdateUserJob
|
|
310
|
-
end
|
|
311
|
-
```
|
|
131
|
+
`ActiveJob::UnknownJobClassError` will be raised instead of a more generic
|
|
132
|
+
`NameError` to make it easily possible for adapters to tell if the `NameError`
|
|
133
|
+
was raised during job execution or deserialization.
|
|
312
134
|
|
|
313
|
-
*
|
|
135
|
+
*Earlopain*
|
|
314
136
|
|
|
315
|
-
Please check [
|
|
137
|
+
Please check [8-0-stable](https://github.com/rails/rails/blob/8-0-stable/activejob/CHANGELOG.md) for previous changes.
|
data/README.md
CHANGED
|
@@ -89,11 +89,13 @@ Active Job has built-in adapters for multiple queuing backends (Sidekiq,
|
|
|
89
89
|
Resque, Delayed Job and others). To get an up-to-date list of the adapters
|
|
90
90
|
see the API Documentation for [ActiveJob::QueueAdapters](https://api.rubyonrails.org/classes/ActiveJob/QueueAdapters.html).
|
|
91
91
|
|
|
92
|
-
**Please note:** We are not accepting pull requests for new adapters
|
|
93
|
-
|
|
94
|
-
their gem, or as a stand-alone gem.
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
**Please note:** We are not accepting pull requests for new adapters, and we are
|
|
93
|
+
actively extracting the current adapters. We encourage library authors to provide
|
|
94
|
+
an Active Job adapter as part of their gem, or as a stand-alone gem.
|
|
95
|
+
|
|
96
|
+
## Continuations
|
|
97
|
+
|
|
98
|
+
Continuations allow jobs to be interrupted and resumed. See more at ActiveJob::Continuation.
|
|
97
99
|
|
|
98
100
|
|
|
99
101
|
## Download and installation
|
|
@@ -126,6 +128,6 @@ Bug reports for the Ruby on \Rails project can be filed here:
|
|
|
126
128
|
|
|
127
129
|
* https://github.com/rails/rails/issues
|
|
128
130
|
|
|
129
|
-
Feature requests should be discussed on the
|
|
131
|
+
Feature requests should be discussed on the rubyonrails-core forum here:
|
|
130
132
|
|
|
131
133
|
* https://discuss.rubyonrails.org/c/rubyonrails-core
|
data/lib/active_job/arguments.rb
CHANGED
|
@@ -35,6 +35,46 @@ module ActiveJob
|
|
|
35
35
|
arguments.map { |argument| serialize_argument(argument) }
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
def serialize_argument(argument) # :nodoc:
|
|
39
|
+
case argument
|
|
40
|
+
when nil, true, false, Integer, Float # Types that can hardly be subclassed
|
|
41
|
+
argument
|
|
42
|
+
when String
|
|
43
|
+
if argument.class == String
|
|
44
|
+
argument
|
|
45
|
+
else
|
|
46
|
+
begin
|
|
47
|
+
Serializers.serialize(argument)
|
|
48
|
+
rescue SerializationError
|
|
49
|
+
argument
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
when Symbol
|
|
53
|
+
{ Serializers::OBJECT_SERIALIZER_KEY => "ActiveJob::Serializers::SymbolSerializer", "value" => argument.name }
|
|
54
|
+
when GlobalID::Identification
|
|
55
|
+
convert_to_global_id_hash(argument)
|
|
56
|
+
when Array
|
|
57
|
+
argument.map { |arg| serialize_argument(arg) }
|
|
58
|
+
when ActiveSupport::HashWithIndifferentAccess
|
|
59
|
+
serialize_indifferent_hash(argument)
|
|
60
|
+
when Hash
|
|
61
|
+
symbol_keys = argument.keys
|
|
62
|
+
symbol_keys.select! { |k| k.is_a?(Symbol) }
|
|
63
|
+
symbol_keys.map!(&:name)
|
|
64
|
+
|
|
65
|
+
aj_hash_key = if Hash.ruby2_keywords_hash?(argument)
|
|
66
|
+
RUBY2_KEYWORDS_KEY
|
|
67
|
+
else
|
|
68
|
+
SYMBOL_KEYS_KEY
|
|
69
|
+
end
|
|
70
|
+
result = serialize_hash(argument)
|
|
71
|
+
result[aj_hash_key] = symbol_keys
|
|
72
|
+
result
|
|
73
|
+
else
|
|
74
|
+
Serializers.serialize(argument)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
38
78
|
# Deserializes a set of arguments. Intrinsic types that can safely be
|
|
39
79
|
# deserialized without mutation are returned as-is. Arrays/Hashes are
|
|
40
80
|
# deserialized element by element. All other types are deserialized using
|
|
@@ -54,74 +94,22 @@ module ActiveJob
|
|
|
54
94
|
RUBY2_KEYWORDS_KEY = "_aj_ruby2_keywords"
|
|
55
95
|
# :nodoc:
|
|
56
96
|
WITH_INDIFFERENT_ACCESS_KEY = "_aj_hash_with_indifferent_access"
|
|
57
|
-
# :nodoc:
|
|
58
|
-
OBJECT_SERIALIZER_KEY = "_aj_serialized"
|
|
59
97
|
|
|
60
98
|
# :nodoc:
|
|
61
99
|
RESERVED_KEYS = [
|
|
62
100
|
GLOBALID_KEY, GLOBALID_KEY.to_sym,
|
|
63
101
|
SYMBOL_KEYS_KEY, SYMBOL_KEYS_KEY.to_sym,
|
|
64
102
|
RUBY2_KEYWORDS_KEY, RUBY2_KEYWORDS_KEY.to_sym,
|
|
65
|
-
OBJECT_SERIALIZER_KEY, OBJECT_SERIALIZER_KEY.to_sym,
|
|
103
|
+
Serializers::OBJECT_SERIALIZER_KEY, Serializers::OBJECT_SERIALIZER_KEY.to_sym,
|
|
66
104
|
WITH_INDIFFERENT_ACCESS_KEY, WITH_INDIFFERENT_ACCESS_KEY.to_sym,
|
|
67
|
-
]
|
|
105
|
+
].to_set
|
|
68
106
|
private_constant :RESERVED_KEYS, :GLOBALID_KEY,
|
|
69
107
|
:SYMBOL_KEYS_KEY, :RUBY2_KEYWORDS_KEY, :WITH_INDIFFERENT_ACCESS_KEY
|
|
70
108
|
|
|
71
|
-
def serialize_argument(argument)
|
|
72
|
-
case argument
|
|
73
|
-
when nil, true, false, Integer, Float # Types that can hardly be subclassed
|
|
74
|
-
argument
|
|
75
|
-
when String
|
|
76
|
-
if argument.class == String
|
|
77
|
-
argument
|
|
78
|
-
else
|
|
79
|
-
begin
|
|
80
|
-
Serializers.serialize(argument)
|
|
81
|
-
rescue SerializationError
|
|
82
|
-
argument
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
when GlobalID::Identification
|
|
86
|
-
convert_to_global_id_hash(argument)
|
|
87
|
-
when Array
|
|
88
|
-
argument.map { |arg| serialize_argument(arg) }
|
|
89
|
-
when ActiveSupport::HashWithIndifferentAccess
|
|
90
|
-
serialize_indifferent_hash(argument)
|
|
91
|
-
when Hash
|
|
92
|
-
symbol_keys = argument.each_key.grep(Symbol).map!(&:to_s)
|
|
93
|
-
aj_hash_key = if Hash.ruby2_keywords_hash?(argument)
|
|
94
|
-
RUBY2_KEYWORDS_KEY
|
|
95
|
-
else
|
|
96
|
-
SYMBOL_KEYS_KEY
|
|
97
|
-
end
|
|
98
|
-
result = serialize_hash(argument)
|
|
99
|
-
result[aj_hash_key] = symbol_keys
|
|
100
|
-
result
|
|
101
|
-
else
|
|
102
|
-
if argument.respond_to?(:permitted?) && argument.respond_to?(:to_h)
|
|
103
|
-
serialize_indifferent_hash(argument.to_h)
|
|
104
|
-
elsif BigDecimal === argument && !ActiveJob.use_big_decimal_serializer
|
|
105
|
-
ActiveJob.deprecator.warn(<<~MSG)
|
|
106
|
-
Primitive serialization of BigDecimal job arguments is deprecated as it may serialize via .to_s using certain queue adapters.
|
|
107
|
-
Enable config.active_job.use_big_decimal_serializer to use BigDecimalSerializer instead, which will be mandatory in Rails 7.2.
|
|
108
|
-
|
|
109
|
-
Note that if your application has multiple replicas, you should only enable this setting after successfully deploying your app to Rails 7.1 first.
|
|
110
|
-
This will ensure that during your deployment all replicas are capable of deserializing arguments serialized with BigDecimalSerializer.
|
|
111
|
-
MSG
|
|
112
|
-
argument
|
|
113
|
-
else
|
|
114
|
-
Serializers.serialize(argument)
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
109
|
def deserialize_argument(argument)
|
|
120
110
|
case argument
|
|
121
111
|
when nil, true, false, String, Integer, Float
|
|
122
112
|
argument
|
|
123
|
-
when BigDecimal # BigDecimal may have been legacy serialized; Remove in 7.2
|
|
124
|
-
argument
|
|
125
113
|
when Array
|
|
126
114
|
argument.map { |arg| deserialize_argument(arg) }
|
|
127
115
|
when Hash
|
|
@@ -146,7 +134,7 @@ module ActiveJob
|
|
|
146
134
|
end
|
|
147
135
|
|
|
148
136
|
def custom_serialized?(hash)
|
|
149
|
-
hash.key?(OBJECT_SERIALIZER_KEY)
|
|
137
|
+
hash.key?(Serializers::OBJECT_SERIALIZER_KEY)
|
|
150
138
|
end
|
|
151
139
|
|
|
152
140
|
def serialize_hash(argument)
|
|
@@ -170,10 +158,12 @@ module ActiveJob
|
|
|
170
158
|
|
|
171
159
|
def serialize_hash_key(key)
|
|
172
160
|
case key
|
|
173
|
-
when
|
|
161
|
+
when RESERVED_KEYS
|
|
174
162
|
raise SerializationError.new("Can't serialize a Hash with reserved key #{key.inspect}")
|
|
175
|
-
when String
|
|
176
|
-
key
|
|
163
|
+
when String
|
|
164
|
+
key
|
|
165
|
+
when Symbol
|
|
166
|
+
key.name
|
|
177
167
|
else
|
|
178
168
|
raise SerializationError.new("Only string and symbol hash keys may be serialized as job arguments, but #{key.inspect} is a #{key.class}")
|
|
179
169
|
end
|
|
@@ -181,7 +171,7 @@ module ActiveJob
|
|
|
181
171
|
|
|
182
172
|
def serialize_indifferent_hash(indifferent_hash)
|
|
183
173
|
result = serialize_hash(indifferent_hash)
|
|
184
|
-
result[WITH_INDIFFERENT_ACCESS_KEY] =
|
|
174
|
+
result[WITH_INDIFFERENT_ACCESS_KEY] = true
|
|
185
175
|
result
|
|
186
176
|
end
|
|
187
177
|
|
|
@@ -205,4 +195,6 @@ module ActiveJob
|
|
|
205
195
|
"without an id. (Maybe you forgot to call save?)"
|
|
206
196
|
end
|
|
207
197
|
end
|
|
198
|
+
|
|
199
|
+
ActiveSupport.run_load_hooks(:active_job_arguments, Arguments)
|
|
208
200
|
end
|
data/lib/active_job/base.rb
CHANGED
|
@@ -9,10 +9,10 @@ require "active_job/execution"
|
|
|
9
9
|
require "active_job/callbacks"
|
|
10
10
|
require "active_job/exceptions"
|
|
11
11
|
require "active_job/log_subscriber"
|
|
12
|
+
require "active_job/structured_event_subscriber"
|
|
12
13
|
require "active_job/logging"
|
|
13
14
|
require "active_job/instrumentation"
|
|
14
|
-
require "active_job/
|
|
15
|
-
require "active_job/translation"
|
|
15
|
+
require "active_job/execution_state"
|
|
16
16
|
|
|
17
17
|
module ActiveJob # :nodoc:
|
|
18
18
|
# = Active Job \Base
|
|
@@ -40,7 +40,7 @@ module ActiveJob # :nodoc:
|
|
|
40
40
|
# end
|
|
41
41
|
#
|
|
42
42
|
# Records that are passed in are serialized/deserialized using Global
|
|
43
|
-
# ID. More information can be found in Arguments.
|
|
43
|
+
# ID. More information can be found in ActiveJob::Arguments.
|
|
44
44
|
#
|
|
45
45
|
# To enqueue a job to be performed as soon as the queuing system is free:
|
|
46
46
|
#
|
|
@@ -50,7 +50,7 @@ module ActiveJob # :nodoc:
|
|
|
50
50
|
#
|
|
51
51
|
# ProcessPhotoJob.set(wait_until: Date.tomorrow.noon).perform_later(photo)
|
|
52
52
|
#
|
|
53
|
-
# More information can be found in ActiveJob::Core::ClassMethods#set
|
|
53
|
+
# More information can be found in ActiveJob::Core::ClassMethods#set.
|
|
54
54
|
#
|
|
55
55
|
# A job can also be processed immediately without sending to the queue:
|
|
56
56
|
#
|
|
@@ -71,8 +71,7 @@ module ActiveJob # :nodoc:
|
|
|
71
71
|
include Exceptions
|
|
72
72
|
include Instrumentation
|
|
73
73
|
include Logging
|
|
74
|
-
include
|
|
75
|
-
include Translation
|
|
74
|
+
include ExecutionState
|
|
76
75
|
|
|
77
76
|
ActiveSupport.run_load_hooks(:active_job, self)
|
|
78
77
|
end
|
data/lib/active_job/callbacks.rb
CHANGED
|
@@ -15,9 +15,6 @@ module ActiveJob
|
|
|
15
15
|
# * <tt>before_perform</tt>
|
|
16
16
|
# * <tt>around_perform</tt>
|
|
17
17
|
# * <tt>after_perform</tt>
|
|
18
|
-
#
|
|
19
|
-
# NOTE: Calling the same callback multiple times will overwrite previous callback definitions.
|
|
20
|
-
#
|
|
21
18
|
module Callbacks
|
|
22
19
|
extend ActiveSupport::Concern
|
|
23
20
|
include ActiveSupport::Callbacks
|
|
@@ -12,11 +12,12 @@ module ActiveJob
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def perform_later(...)
|
|
15
|
-
@job_class.new(...)
|
|
16
|
-
|
|
15
|
+
job = @job_class.new(...)
|
|
16
|
+
enqueue_result = job.enqueue(@options)
|
|
17
|
+
|
|
18
|
+
yield job if block_given?
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
@job_class.perform_all_later(multi_args, options: @options)
|
|
20
|
+
enqueue_result
|
|
20
21
|
end
|
|
21
22
|
end
|
|
22
23
|
end
|