activejob 7.0.4 → 7.1.5.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 +222 -94
- data/MIT-LICENSE +1 -1
- data/README.md +4 -4
- data/lib/active_job/arguments.rb +28 -31
- data/lib/active_job/base.rb +1 -1
- data/lib/active_job/callbacks.rb +3 -5
- data/lib/active_job/configured_job.rb +4 -0
- data/lib/active_job/core.rb +26 -6
- data/lib/active_job/deprecator.rb +7 -0
- data/lib/active_job/enqueuing.rb +31 -3
- data/lib/active_job/exceptions.rb +52 -8
- data/lib/active_job/execution.rb +11 -2
- data/lib/active_job/gem_version.rb +4 -4
- data/lib/active_job/instrumentation.rb +18 -10
- data/lib/active_job/log_subscriber.rb +81 -9
- data/lib/active_job/queue_adapter.rb +13 -2
- data/lib/active_job/queue_adapters/async_adapter.rb +2 -2
- data/lib/active_job/queue_adapters/backburner_adapter.rb +7 -3
- data/lib/active_job/queue_adapters/delayed_job_adapter.rb +3 -1
- data/lib/active_job/queue_adapters/inline_adapter.rb +1 -1
- data/lib/active_job/queue_adapters/queue_classic_adapter.rb +4 -4
- data/lib/active_job/queue_adapters/resque_adapter.rb +1 -1
- data/lib/active_job/queue_adapters/sidekiq_adapter.rb +42 -14
- data/lib/active_job/queue_adapters/sneakers_adapter.rb +1 -1
- data/lib/active_job/queue_adapters/sucker_punch_adapter.rb +3 -3
- data/lib/active_job/queue_adapters/test_adapter.rb +3 -3
- data/lib/active_job/queue_adapters.rb +8 -7
- data/lib/active_job/queue_name.rb +1 -2
- data/lib/active_job/queue_priority.rb +18 -1
- data/lib/active_job/railtie.rb +26 -7
- data/lib/active_job/serializers/big_decimal_serializer.rb +22 -0
- data/lib/active_job/serializers/duration_serializer.rb +4 -2
- data/lib/active_job/serializers/time_with_zone_serializer.rb +11 -2
- data/lib/active_job/serializers.rb +7 -3
- data/lib/active_job/test_helper.rb +32 -14
- data/lib/active_job/version.rb +1 -1
- data/lib/active_job.rb +29 -4
- data/lib/rails/generators/job/USAGE +19 -0
- data/lib/rails/generators/job/job_generator.rb +6 -2
- data/lib/rails/generators/job/templates/job.rb.tt +1 -1
- metadata +14 -12
- data/lib/active_job/queue_adapters/que_adapter.rb +0 -61
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3163adeb0ad6bf21b0048cfcde214b97af34a0b49299f37cd2e93905a5839327
|
4
|
+
data.tar.gz: ccaff11c2aa436b1ad0b7a479c030c7e241ee8e2c0a4754361ac6acb6a703d5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d319ffd95f49cddec8a0fdbc39f36d5029a3d7bc91086564cd673f784268a86d20c3d2977d248a8f7591e80d8652be11d9c9bd0e94afb5cbefad132035d1ad68
|
7
|
+
data.tar.gz: e9eaebe18fc732613af2da14a35d5993f1c4c6e87ff01908fef6f569c51c395150046d1502d913df2bcb4cbeb0c2810bbe2d5a337f8903207e604dabba789509
|
data/CHANGELOG.md
CHANGED
@@ -1,182 +1,310 @@
|
|
1
|
-
## Rails 7.
|
1
|
+
## Rails 7.1.5.1 (December 10, 2024) ##
|
2
2
|
|
3
|
-
*
|
3
|
+
* No changes.
|
4
4
|
|
5
|
-
Remove a deprecation warning introduced in que 1.2 to prepare for changes in
|
6
|
-
que 2.0 necessary for Ruby 3 compatibility.
|
7
5
|
|
8
|
-
|
6
|
+
## Rails 7.1.5 (October 30, 2024) ##
|
7
|
+
|
8
|
+
* No changes.
|
9
9
|
|
10
|
-
|
10
|
+
|
11
|
+
## Rails 7.1.4.2 (October 23, 2024) ##
|
11
12
|
|
12
13
|
* No changes.
|
13
14
|
|
14
15
|
|
15
|
-
## Rails 7.
|
16
|
+
## Rails 7.1.4.1 (October 15, 2024) ##
|
16
17
|
|
17
|
-
*
|
18
|
+
* No changes.
|
18
19
|
|
19
|
-
Could cause `uninitialized constant ActiveJob::Arguments::BigDecimal (NameError)`
|
20
|
-
when loading Active Job in isolation.
|
21
20
|
|
22
|
-
|
21
|
+
## Rails 7.1.4 (August 22, 2024) ##
|
22
|
+
|
23
|
+
* Register autoload for `ActiveJob::Arguments`.
|
24
|
+
|
25
|
+
*Rafael Mendonça França*
|
26
|
+
|
23
27
|
|
24
|
-
## Rails 7.
|
28
|
+
## Rails 7.1.3.4 (June 04, 2024) ##
|
25
29
|
|
26
30
|
* No changes.
|
27
31
|
|
28
32
|
|
29
|
-
## Rails 7.
|
33
|
+
## Rails 7.1.3.3 (May 16, 2024) ##
|
30
34
|
|
31
35
|
* No changes.
|
32
36
|
|
33
37
|
|
34
|
-
## Rails 7.
|
38
|
+
## Rails 7.1.3.2 (February 21, 2024) ##
|
35
39
|
|
36
40
|
* No changes.
|
37
41
|
|
38
42
|
|
39
|
-
## Rails 7.
|
43
|
+
## Rails 7.1.3.1 (February 21, 2024) ##
|
40
44
|
|
41
45
|
* No changes.
|
42
46
|
|
43
47
|
|
44
|
-
## Rails 7.
|
48
|
+
## Rails 7.1.3 (January 16, 2024) ##
|
49
|
+
|
50
|
+
* Do not trigger immediate loading of `ActiveJob::Base` when loading `ActiveJob::TestHelper`.
|
51
|
+
|
52
|
+
*Maxime Réty*
|
53
|
+
|
54
|
+
* Preserve the serialized timezone when deserializing `ActiveSupport::TimeWithZone` arguments.
|
55
|
+
|
56
|
+
*Joshua Young*
|
57
|
+
|
58
|
+
* Fix ActiveJob arguments serialization to correctly serialize String subclasses having custom serializers.
|
59
|
+
|
60
|
+
*fatkodima*
|
61
|
+
|
62
|
+
|
63
|
+
## Rails 7.1.2 (November 10, 2023) ##
|
45
64
|
|
46
65
|
* No changes.
|
47
66
|
|
48
67
|
|
49
|
-
## Rails 7.
|
68
|
+
## Rails 7.1.1 (October 11, 2023) ##
|
50
69
|
|
51
|
-
*
|
70
|
+
* Don't log enqueuing details when the job wasn't enqueued.
|
52
71
|
|
53
|
-
|
54
|
-
was called before calling `perform_now`. When a record no longer exists
|
55
|
-
and is serialized using GlobalID this led to raising
|
56
|
-
an `ActiveJob::DeserializationError` before reaching `perform_now` call.
|
57
|
-
This behaviour makes difficult testing the job `discard_on/retry_on` logic.
|
72
|
+
*Dustin Brown*
|
58
73
|
|
59
|
-
Now `deserialize_arguments_if_needed` call is postponed to when `perform_now`
|
60
|
-
is called.
|
61
74
|
|
62
|
-
|
75
|
+
## Rails 7.1.0 (October 05, 2023) ##
|
76
|
+
|
77
|
+
* No changes.
|
78
|
+
|
79
|
+
|
80
|
+
## Rails 7.1.0.rc2 (October 01, 2023) ##
|
81
|
+
|
82
|
+
* Make sure `scheduled_at` is a Time object when asserting enqueued jobs.
|
83
|
+
|
84
|
+
*Rafael Mendonça França*
|
85
|
+
|
86
|
+
|
87
|
+
## Rails 7.1.0.rc1 (September 27, 2023) ##
|
88
|
+
|
89
|
+
* Set `scheduled_at` attribute as a Time object instead of epoch seconds, and serialize and deserialize the value
|
90
|
+
when enqueued. Assigning a numeric/epoch value to scheduled_at= is deprecated; use a Time object instead.
|
91
|
+
|
92
|
+
Deserializes `enqueued_at` as a Time instead of ISO8601 String.
|
93
|
+
|
94
|
+
*Ben Sheldon*
|
95
|
+
|
96
|
+
* Clarify the backoff strategy for the recommended `:wait` option when retrying jobs
|
97
|
+
|
98
|
+
`wait: :exponentially_longer` is waiting polynomially longer, so it is now recommended to use `wait: :polynomially_longer` to keep the same behavior.
|
99
|
+
|
100
|
+
*Victor Mours*
|
101
|
+
|
102
|
+
|
103
|
+
## Rails 7.1.0.beta1 (September 13, 2023) ##
|
104
|
+
|
105
|
+
* Fix Active Job log message to correctly report a job failed to enqueue
|
106
|
+
when the adapter raises an `ActiveJob::EnqueueError`.
|
107
|
+
|
108
|
+
*Ben Sheldon*
|
109
|
+
|
110
|
+
* Add `after_discard` method.
|
111
|
+
|
112
|
+
This method lets job authors define a block which will be run when a job is about to be discarded. For example:
|
63
113
|
|
64
114
|
```ruby
|
65
|
-
class
|
66
|
-
|
115
|
+
class AfterDiscardJob < ActiveJob::Base
|
116
|
+
after_discard do |job, exception|
|
117
|
+
Rails.logger.info("#{job.class} raised an exception: #{exception}")
|
118
|
+
end
|
67
119
|
|
68
|
-
def perform
|
69
|
-
|
120
|
+
def perform
|
121
|
+
raise StandardError
|
70
122
|
end
|
71
123
|
end
|
124
|
+
```
|
125
|
+
|
126
|
+
The above job will run the block passed to `after_discard` after the job is discarded. The exception will
|
127
|
+
still be raised after the block has been run.
|
128
|
+
|
129
|
+
*Rob Cardy*
|
130
|
+
|
131
|
+
* Fix deserialization of ActiveSupport::Duration
|
132
|
+
|
133
|
+
Previously, a deserialized Duration would return an array from Duration#parts.
|
134
|
+
It will now return a hash just like a regular Duration.
|
135
|
+
|
136
|
+
This also fixes an error when trying to add or subtract from a deserialized Duration
|
137
|
+
(eg `duration + 1.year`).
|
138
|
+
|
139
|
+
*Jonathan del Strother*
|
140
|
+
|
141
|
+
* `perform_enqueued_jobs` is now compatible with all Active Job adapters
|
142
|
+
|
143
|
+
This means that methods that depend on it, like Action Mailer's `assert_emails`,
|
144
|
+
will work correctly even if the test adapter is not used.
|
145
|
+
|
146
|
+
*Alex Ghiculescu*
|
147
|
+
|
148
|
+
* Allow queue adapters to provide a custom name by implementing `queue_adapter_name`
|
149
|
+
|
150
|
+
*Sander Verdonschot*
|
151
|
+
|
152
|
+
* Log background job enqueue callers
|
153
|
+
|
154
|
+
Add `verbose_enqueue_logs` configuration option to display the caller
|
155
|
+
of background job enqueue in the log to help with debugging.
|
156
|
+
|
157
|
+
Example log line:
|
72
158
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
perform_enqueued_jobs only: UpdateUserJob
|
77
|
-
end
|
159
|
+
```
|
160
|
+
Enqueued AvatarThumbnailsJob (Job ID: ab528951-41fb-4c48-9129-3171791c27d6) to Sidekiq(default) with arguments: 1092412064
|
161
|
+
↳ app/models/user.rb:421:in `generate_avatar_thumbnails'
|
78
162
|
```
|
79
163
|
|
80
|
-
|
164
|
+
Enabled in development only for new and upgraded applications. Not recommended for use
|
165
|
+
in the production environment since it relies on Ruby's `Kernel#caller` which is fairly slow.
|
81
166
|
|
167
|
+
*fatkodima*
|
82
168
|
|
83
|
-
|
169
|
+
* Set `provider_job_id` for Backburner jobs
|
84
170
|
|
85
|
-
*
|
171
|
+
*Cameron Matheson*
|
86
172
|
|
173
|
+
* Add `perform_all_later` to enqueue multiple jobs at once
|
87
174
|
|
88
|
-
|
175
|
+
This adds the ability to bulk enqueue jobs, without running callbacks, by
|
176
|
+
passing multiple jobs or an array of jobs. For example:
|
89
177
|
|
90
|
-
|
178
|
+
```ruby
|
179
|
+
ActiveJob.perform_all_later(MyJob.new("hello", 42), MyJob.new("world", 0))
|
91
180
|
|
181
|
+
user_jobs = User.pluck(:id).map { |id| UserJob.new(user_id: id) }
|
182
|
+
ActiveJob.perform_all_later(user_jobs)
|
183
|
+
```
|
92
184
|
|
93
|
-
|
185
|
+
This can greatly reduce the number of round-trips to the queue datastore.
|
186
|
+
For queue adapters that do not implement the new `enqueue_all` method, we
|
187
|
+
fall back to enqueuing jobs individually. The Sidekiq adapter implements
|
188
|
+
`enqueue_all` with `push_bulk`.
|
94
189
|
|
95
|
-
|
190
|
+
This method does not use the existing `enqueue.active_job` event, but adds a
|
191
|
+
new event `enqueue_all.active_job`.
|
96
192
|
|
97
|
-
|
193
|
+
*Sander Verdonschot*
|
98
194
|
|
99
|
-
*
|
195
|
+
* Don't double log the `job` when using `ActiveRecord::QueryLog`
|
100
196
|
|
101
|
-
|
197
|
+
Previously if you set `config.active_record.query_log_tags` to an array that included
|
198
|
+
`:job`, the job name would get logged twice. This bug has been fixed.
|
102
199
|
|
103
|
-
*
|
200
|
+
*Alex Ghiculescu*
|
104
201
|
|
105
|
-
|
202
|
+
* Add support for Sidekiq's transaction-aware client
|
106
203
|
|
107
|
-
*
|
108
|
-
previous callback was halted with `throw :abort`.
|
204
|
+
*Jonathan del Strother*
|
109
205
|
|
110
|
-
|
206
|
+
* Remove QueAdapter from Active Job.
|
111
207
|
|
112
|
-
|
113
|
-
|
208
|
+
After maintaining Active Job QueAdapter by Rails and Que side
|
209
|
+
to support Ruby 3 keyword arguments and options provided as top level keywords,
|
210
|
+
it is quite difficult to maintain it this way.
|
114
211
|
|
115
|
-
|
212
|
+
Active Job Que adapter can be included in the future version of que gem itself.
|
116
213
|
|
214
|
+
*Yasuo Honda*
|
117
215
|
|
118
|
-
|
216
|
+
* Fix BigDecimal (de)serialization for adapters using JSON.
|
119
217
|
|
120
|
-
|
218
|
+
Previously, BigDecimal was listed as not needing a serializer. However,
|
219
|
+
when used with an adapter storing the job arguments as JSON, it would get
|
220
|
+
serialized as a simple String, resulting in deserialization also producing
|
221
|
+
a String (instead of a BigDecimal).
|
121
222
|
|
223
|
+
By using a serializer, we ensure the round trip is safe.
|
122
224
|
|
123
|
-
|
225
|
+
To ensure applications using BigDecimal job arguments are not subject to
|
226
|
+
race conditions during deployment (where a replica running a version of
|
227
|
+
Rails without BigDecimalSerializer fails to deserialize an argument
|
228
|
+
serialized with it), `ActiveJob.use_big_decimal_serializer` is disabled by
|
229
|
+
default, and can be set to true in a following deployment..
|
124
230
|
|
125
|
-
*
|
231
|
+
*Sam Bostock*
|
126
232
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
forever until it succeeds.
|
233
|
+
* Preserve full-precision `enqueued_at` timestamps for serialized jobs,
|
234
|
+
allowing more accurate reporting of how long a job spent waiting in the
|
235
|
+
queue before it was performed.
|
131
236
|
|
132
|
-
|
133
|
-
retry_on(AlwaysRetryException, attempts: :unlimited)
|
237
|
+
Retains IS08601 format compatibility.
|
134
238
|
|
135
|
-
|
136
|
-
end
|
239
|
+
*Jeremy Daer*
|
137
240
|
|
138
|
-
|
241
|
+
* Add `--parent` option to job generator to specify parent class of job.
|
139
242
|
|
140
|
-
|
141
|
-
`assert_enqueued_with` and `assert_performed_with`.
|
243
|
+
Example:
|
142
244
|
|
143
|
-
|
245
|
+
`bin/rails g job process_payment --parent=payment_job` generates:
|
144
246
|
|
145
|
-
|
247
|
+
```ruby
|
248
|
+
class ProcessPaymentJob < PaymentJob
|
249
|
+
# ...
|
250
|
+
end
|
251
|
+
```
|
146
252
|
|
147
|
-
*
|
253
|
+
*Gannon McGibbon*
|
148
254
|
|
149
|
-
* Add
|
255
|
+
* Add more detailed description to job generator.
|
150
256
|
|
151
|
-
|
257
|
+
*Gannon McGibbon*
|
152
258
|
|
153
|
-
*
|
259
|
+
* `perform.active_job` notification payloads now include `:db_runtime`, which
|
260
|
+
is the total time (in ms) taken by database queries while performing a job.
|
261
|
+
This value can be used to better understand how a job's time is spent.
|
154
262
|
|
155
|
-
|
156
|
-
the adapter attempts to enqueue the job. The block will receive the job
|
157
|
-
instance as an argument even if the enqueue was not successful.
|
158
|
-
Additionally, `ActiveJob` adapters now have the ability to raise an
|
159
|
-
`ActiveJob::EnqueueError` which will be caught and stored in the job
|
160
|
-
instance so code attempting to enqueue jobs can inspect any raised
|
161
|
-
`EnqueueError` using the block.
|
263
|
+
*Jonathan Hefner*
|
162
264
|
|
163
|
-
|
164
|
-
unless job.successfully_enqueued?
|
165
|
-
if job.enqueue_error&.message == "Redis was unavailable"
|
166
|
-
# invoke some code that will retry the job after a delay
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
265
|
+
* Update `ActiveJob::QueueAdapters::QueAdapter` to remove deprecation warning.
|
170
266
|
|
171
|
-
|
267
|
+
Remove a deprecation warning introduced in que 1.2 to prepare for changes in
|
268
|
+
que 2.0 necessary for Ruby 3 compatibility.
|
172
269
|
|
173
|
-
*
|
270
|
+
*Damir Zekic* and *Adis Hasovic*
|
174
271
|
|
175
|
-
|
272
|
+
* Add missing `bigdecimal` require in `ActiveJob::Arguments`
|
176
273
|
|
177
|
-
|
274
|
+
Could cause `uninitialized constant ActiveJob::Arguments::BigDecimal (NameError)`
|
275
|
+
when loading Active Job in isolation.
|
276
|
+
|
277
|
+
*Jean Boussier*
|
278
|
+
|
279
|
+
* Allow testing `discard_on/retry_on ActiveJob::DeserializationError`
|
280
|
+
|
281
|
+
Previously in `perform_enqueued_jobs`, `deserialize_arguments_if_needed`
|
282
|
+
was called before calling `perform_now`. When a record no longer exists
|
283
|
+
and is serialized using GlobalID this led to raising
|
284
|
+
an `ActiveJob::DeserializationError` before reaching `perform_now` call.
|
285
|
+
This behavior makes difficult testing the job `discard_on/retry_on` logic.
|
286
|
+
|
287
|
+
Now `deserialize_arguments_if_needed` call is postponed to when `perform_now`
|
288
|
+
is called.
|
289
|
+
|
290
|
+
Example:
|
178
291
|
|
179
|
-
|
292
|
+
```ruby
|
293
|
+
class UpdateUserJob < ActiveJob::Base
|
294
|
+
discard_on ActiveJob::DeserializationError
|
295
|
+
|
296
|
+
def perform(user)
|
297
|
+
# ...
|
298
|
+
end
|
299
|
+
end
|
180
300
|
|
301
|
+
# In the test
|
302
|
+
User.destroy_all
|
303
|
+
assert_nothing_raised do
|
304
|
+
perform_enqueued_jobs only: UpdateUserJob
|
305
|
+
end
|
306
|
+
```
|
307
|
+
|
308
|
+
*Jacopo Beschi*
|
181
309
|
|
182
|
-
Please check [
|
310
|
+
Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/activejob/CHANGELOG.md) for previous changes.
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -10,14 +10,14 @@ that makes it easy to turn any mailing into a job for running later. That's
|
|
10
10
|
one of the most common jobs in a modern web application: sending emails outside
|
11
11
|
the request-response cycle, so the user doesn't have to wait on it.
|
12
12
|
|
13
|
-
The main point is to ensure that all Rails apps will have a job infrastructure
|
13
|
+
The main point is to ensure that all \Rails apps will have a job infrastructure
|
14
14
|
in place, even if it's in the form of an "immediate runner". We can then have
|
15
15
|
framework features and other gems build on top of that, without having to worry
|
16
16
|
about API differences between Delayed Job and Resque. Picking your queuing
|
17
17
|
backend becomes more of an operational concern, then. And you'll be able to
|
18
18
|
switch between them without having to rewrite your jobs.
|
19
19
|
|
20
|
-
You can read more about Active Job in the [Active Job Basics](https://
|
20
|
+
You can read more about Active Job in the [Active Job Basics](https://guides.rubyonrails.org/active_job_basics.html) guide.
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
@@ -104,7 +104,7 @@ The latest version of Active Job can be installed with RubyGems:
|
|
104
104
|
$ gem install activejob
|
105
105
|
```
|
106
106
|
|
107
|
-
Source code can be downloaded as part of the Rails project on GitHub:
|
107
|
+
Source code can be downloaded as part of the \Rails project on GitHub:
|
108
108
|
|
109
109
|
* https://github.com/rails/rails/tree/main/activejob
|
110
110
|
|
@@ -122,7 +122,7 @@ API documentation is at:
|
|
122
122
|
|
123
123
|
* https://api.rubyonrails.org
|
124
124
|
|
125
|
-
Bug reports for the Ruby on Rails project can be filed here:
|
125
|
+
Bug reports for the Ruby on \Rails project can be filed here:
|
126
126
|
|
127
127
|
* https://github.com/rails/rails/issues
|
128
128
|
|
data/lib/active_job/arguments.rb
CHANGED
@@ -46,8 +46,6 @@ module ActiveJob
|
|
46
46
|
end
|
47
47
|
|
48
48
|
private
|
49
|
-
# :nodoc:
|
50
|
-
PERMITTED_TYPES = [ NilClass, String, Integer, Float, BigDecimal, TrueClass, FalseClass ]
|
51
49
|
# :nodoc:
|
52
50
|
GLOBALID_KEY = "_aj_globalid"
|
53
51
|
# :nodoc:
|
@@ -67,35 +65,23 @@ module ActiveJob
|
|
67
65
|
OBJECT_SERIALIZER_KEY, OBJECT_SERIALIZER_KEY.to_sym,
|
68
66
|
WITH_INDIFFERENT_ACCESS_KEY, WITH_INDIFFERENT_ACCESS_KEY.to_sym,
|
69
67
|
]
|
70
|
-
private_constant :
|
68
|
+
private_constant :RESERVED_KEYS, :GLOBALID_KEY,
|
71
69
|
:SYMBOL_KEYS_KEY, :RUBY2_KEYWORDS_KEY, :WITH_INDIFFERENT_ACCESS_KEY
|
72
70
|
|
73
|
-
unless Hash.respond_to?(:ruby2_keywords_hash?) && Hash.respond_to?(:ruby2_keywords_hash)
|
74
|
-
using Module.new {
|
75
|
-
refine Hash do
|
76
|
-
class << Hash
|
77
|
-
def ruby2_keywords_hash?(hash)
|
78
|
-
!new(*[hash]).default.equal?(hash)
|
79
|
-
end
|
80
|
-
|
81
|
-
def ruby2_keywords_hash(hash)
|
82
|
-
_ruby2_keywords_hash(**hash)
|
83
|
-
end
|
84
|
-
|
85
|
-
private
|
86
|
-
def _ruby2_keywords_hash(*args)
|
87
|
-
args.last
|
88
|
-
end
|
89
|
-
ruby2_keywords(:_ruby2_keywords_hash)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
}
|
93
|
-
end
|
94
|
-
|
95
71
|
def serialize_argument(argument)
|
96
72
|
case argument
|
97
|
-
when
|
73
|
+
when nil, true, false, Integer, Float # Types that can hardly be subclassed
|
98
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
|
99
85
|
when GlobalID::Identification
|
100
86
|
convert_to_global_id_hash(argument)
|
101
87
|
when Array
|
@@ -112,18 +98,29 @@ module ActiveJob
|
|
112
98
|
result = serialize_hash(argument)
|
113
99
|
result[aj_hash_key] = symbol_keys
|
114
100
|
result
|
115
|
-
when -> (arg) { arg.respond_to?(:permitted?) }
|
116
|
-
serialize_indifferent_hash(argument.to_h)
|
117
101
|
else
|
118
|
-
|
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
|
119
116
|
end
|
120
117
|
end
|
121
118
|
|
122
119
|
def deserialize_argument(argument)
|
123
120
|
case argument
|
124
|
-
when String
|
121
|
+
when nil, true, false, String, Integer, Float
|
125
122
|
argument
|
126
|
-
when
|
123
|
+
when BigDecimal # BigDecimal may have been legacy serialized; Remove in 7.2
|
127
124
|
argument
|
128
125
|
when Array
|
129
126
|
argument.map { |arg| deserialize_argument(arg) }
|
data/lib/active_job/base.rb
CHANGED
@@ -15,7 +15,7 @@ require "active_job/timezones"
|
|
15
15
|
require "active_job/translation"
|
16
16
|
|
17
17
|
module ActiveJob # :nodoc:
|
18
|
-
# = Active Job
|
18
|
+
# = Active Job \Base
|
19
19
|
#
|
20
20
|
# Active Job objects can be configured to work with different backend
|
21
21
|
# queuing frameworks. To specify a queue adapter to use:
|
data/lib/active_job/callbacks.rb
CHANGED
@@ -4,7 +4,7 @@ require "active_support/callbacks"
|
|
4
4
|
require "active_support/core_ext/module/attribute_accessors"
|
5
5
|
|
6
6
|
module ActiveJob
|
7
|
-
# = Active Job Callbacks
|
7
|
+
# = Active Job \Callbacks
|
8
8
|
#
|
9
9
|
# Active Job provides hooks during the life cycle of a job. Callbacks allow you
|
10
10
|
# to trigger logic during this cycle. Available callbacks are:
|
@@ -28,9 +28,6 @@ module ActiveJob
|
|
28
28
|
end
|
29
29
|
|
30
30
|
included do
|
31
|
-
cattr_accessor :skip_after_callbacks_if_terminated, instance_accessor: false, default: false
|
32
|
-
singleton_class.deprecate :skip_after_callbacks_if_terminated, :skip_after_callbacks_if_terminated=
|
33
|
-
|
34
31
|
define_callbacks :perform, skip_after_callbacks_if_terminated: true
|
35
32
|
define_callbacks :enqueue, skip_after_callbacks_if_terminated: true
|
36
33
|
end
|
@@ -135,7 +132,8 @@ module ActiveJob
|
|
135
132
|
# queue_as :default
|
136
133
|
#
|
137
134
|
# after_enqueue do |job|
|
138
|
-
#
|
135
|
+
# result = job.successfully_enqueued? ? "success" : "failure"
|
136
|
+
# $statsd.increment "enqueue-video-job.#{result}"
|
139
137
|
# end
|
140
138
|
#
|
141
139
|
# def perform(video_id)
|