activejob 6.0.2.1 → 6.0.3.2
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 +27 -0
- data/README.md +1 -1
- data/lib/active_job/arguments.rb +42 -4
- data/lib/active_job/configured_job.rb +2 -0
- data/lib/active_job/core.rb +1 -0
- data/lib/active_job/enqueuing.rb +2 -0
- data/lib/active_job/exceptions.rb +1 -1
- data/lib/active_job/execution.rb +1 -0
- data/lib/active_job/gem_version.rb +2 -2
- data/lib/active_job/queue_adapters/que_adapter.rb +2 -2
- data/lib/active_job/queue_adapters/test_adapter.rb +8 -8
- data/lib/active_job/serializers/date_serializer.rb +0 -1
- data/lib/active_job/serializers/date_time_serializer.rb +0 -1
- data/lib/active_job/serializers/duration_serializer.rb +0 -1
- data/lib/active_job/serializers/object_serializer.rb +0 -1
- data/lib/active_job/serializers/symbol_serializer.rb +0 -1
- data/lib/active_job/serializers/time_serializer.rb +0 -1
- data/lib/active_job/serializers/time_with_zone_serializer.rb +0 -1
- data/lib/active_job/test_helper.rb +36 -10
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aa67f26abfc254d6855b0067f396a253241fdc74df407f4261d3dacb7235c48
|
4
|
+
data.tar.gz: d42e8410e3aaabd94cc68fb3ca300fd30a5a0ed2806be1ffcb036f1accd62c9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d9937f4a3f5c0a3b062f2f6ad4db4db30ce9893c4423f2e49c7fedcb8ecd01fa101e1ee36dcbe670d2538bc440f8bd83dc4bfb3114515bd84d3d68202211ae2
|
7
|
+
data.tar.gz: 02baf8feb8d09b07c190ff90c40d40d880ad6eed7ecd672fff080910839ea5139a4f5deaeb2006b0f5269cda5d587e5cf9b7890e368e4d43f0e30b7c267516c7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
+
## Rails 6.0.3.2 (June 17, 2020) ##
|
2
|
+
|
3
|
+
* No changes.
|
4
|
+
|
5
|
+
|
6
|
+
## Rails 6.0.3.1 (May 18, 2020) ##
|
7
|
+
|
8
|
+
* No changes.
|
9
|
+
|
10
|
+
|
11
|
+
## Rails 6.0.3 (May 06, 2020) ##
|
12
|
+
|
13
|
+
* While using `perform_enqueued_jobs` test helper enqueued jobs must be stored for the later check with
|
14
|
+
`assert_enqueued_with`.
|
15
|
+
|
16
|
+
*Dmitry Polushkin*
|
17
|
+
|
18
|
+
* Add queue name support to Que adapter
|
19
|
+
|
20
|
+
*Brad Nauta*, *Wojciech Wnętrzak*
|
21
|
+
|
22
|
+
|
23
|
+
## Rails 6.0.2.2 (March 19, 2020) ##
|
24
|
+
|
25
|
+
* No changes.
|
26
|
+
|
27
|
+
|
1
28
|
## Rails 6.0.2.1 (December 18, 2019) ##
|
2
29
|
|
3
30
|
* No changes.
|
data/README.md
CHANGED
@@ -130,4 +130,4 @@ Bug reports for the Ruby on Rails project can be filed here:
|
|
130
130
|
|
131
131
|
Feature requests should be discussed on the rails-core mailing list here:
|
132
132
|
|
133
|
-
* https://
|
133
|
+
* https://discuss.rubyonrails.org/c/rubyonrails-core
|
data/lib/active_job/arguments.rb
CHANGED
@@ -45,7 +45,6 @@ module ActiveJob
|
|
45
45
|
end
|
46
46
|
|
47
47
|
private
|
48
|
-
|
49
48
|
# :nodoc:
|
50
49
|
PERMITTED_TYPES = [ NilClass, String, Integer, Float, BigDecimal, TrueClass, FalseClass ]
|
51
50
|
# :nodoc:
|
@@ -53,6 +52,8 @@ module ActiveJob
|
|
53
52
|
# :nodoc:
|
54
53
|
SYMBOL_KEYS_KEY = "_aj_symbol_keys"
|
55
54
|
# :nodoc:
|
55
|
+
RUBY2_KEYWORDS_KEY = "_aj_ruby2_keywords"
|
56
|
+
# :nodoc:
|
56
57
|
WITH_INDIFFERENT_ACCESS_KEY = "_aj_hash_with_indifferent_access"
|
57
58
|
# :nodoc:
|
58
59
|
OBJECT_SERIALIZER_KEY = "_aj_serialized"
|
@@ -61,10 +62,39 @@ module ActiveJob
|
|
61
62
|
RESERVED_KEYS = [
|
62
63
|
GLOBALID_KEY, GLOBALID_KEY.to_sym,
|
63
64
|
SYMBOL_KEYS_KEY, SYMBOL_KEYS_KEY.to_sym,
|
65
|
+
RUBY2_KEYWORDS_KEY, RUBY2_KEYWORDS_KEY.to_sym,
|
64
66
|
OBJECT_SERIALIZER_KEY, OBJECT_SERIALIZER_KEY.to_sym,
|
65
67
|
WITH_INDIFFERENT_ACCESS_KEY, WITH_INDIFFERENT_ACCESS_KEY.to_sym,
|
66
68
|
]
|
67
|
-
private_constant :PERMITTED_TYPES, :RESERVED_KEYS, :GLOBALID_KEY,
|
69
|
+
private_constant :PERMITTED_TYPES, :RESERVED_KEYS, :GLOBALID_KEY,
|
70
|
+
:SYMBOL_KEYS_KEY, :RUBY2_KEYWORDS_KEY, :WITH_INDIFFERENT_ACCESS_KEY
|
71
|
+
|
72
|
+
unless Hash.respond_to?(:ruby2_keywords_hash?) && Hash.respond_to?(:ruby2_keywords_hash)
|
73
|
+
using Module.new {
|
74
|
+
refine Hash do
|
75
|
+
class << Hash
|
76
|
+
if RUBY_VERSION >= "2.7"
|
77
|
+
def ruby2_keywords_hash?(hash)
|
78
|
+
!new(*[hash]).default.equal?(hash)
|
79
|
+
end
|
80
|
+
else
|
81
|
+
def ruby2_keywords_hash?(hash)
|
82
|
+
false
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def ruby2_keywords_hash(hash)
|
87
|
+
_ruby2_keywords_hash(**hash)
|
88
|
+
end
|
89
|
+
|
90
|
+
private def _ruby2_keywords_hash(*args)
|
91
|
+
args.last
|
92
|
+
end
|
93
|
+
ruby2_keywords(:_ruby2_keywords_hash) if respond_to?(:ruby2_keywords, true)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
}
|
97
|
+
end
|
68
98
|
|
69
99
|
def serialize_argument(argument)
|
70
100
|
case argument
|
@@ -77,9 +107,14 @@ module ActiveJob
|
|
77
107
|
when ActiveSupport::HashWithIndifferentAccess
|
78
108
|
serialize_indifferent_hash(argument)
|
79
109
|
when Hash
|
80
|
-
symbol_keys = argument.each_key.grep(Symbol).map(&:to_s)
|
110
|
+
symbol_keys = argument.each_key.grep(Symbol).map!(&:to_s)
|
111
|
+
aj_hash_key = if Hash.ruby2_keywords_hash?(argument)
|
112
|
+
RUBY2_KEYWORDS_KEY
|
113
|
+
else
|
114
|
+
SYMBOL_KEYS_KEY
|
115
|
+
end
|
81
116
|
result = serialize_hash(argument)
|
82
|
-
result[
|
117
|
+
result[aj_hash_key] = symbol_keys
|
83
118
|
result
|
84
119
|
when -> (arg) { arg.respond_to?(:permitted?) }
|
85
120
|
serialize_indifferent_hash(argument.to_h)
|
@@ -133,6 +168,9 @@ module ActiveJob
|
|
133
168
|
result = result.with_indifferent_access
|
134
169
|
elsif symbol_keys = result.delete(SYMBOL_KEYS_KEY)
|
135
170
|
result = transform_symbol_keys(result, symbol_keys)
|
171
|
+
elsif symbol_keys = result.delete(RUBY2_KEYWORDS_KEY)
|
172
|
+
result = transform_symbol_keys(result, symbol_keys)
|
173
|
+
result = Hash.ruby2_keywords_hash(result)
|
136
174
|
end
|
137
175
|
result
|
138
176
|
end
|
@@ -10,9 +10,11 @@ module ActiveJob
|
|
10
10
|
def perform_now(*args)
|
11
11
|
@job_class.new(*args).perform_now
|
12
12
|
end
|
13
|
+
ruby2_keywords(:perform_now) if respond_to?(:ruby2_keywords, true)
|
13
14
|
|
14
15
|
def perform_later(*args)
|
15
16
|
@job_class.new(*args).enqueue @options
|
16
17
|
end
|
18
|
+
ruby2_keywords(:perform_later) if respond_to?(:ruby2_keywords, true)
|
17
19
|
end
|
18
20
|
end
|
data/lib/active_job/core.rb
CHANGED
data/lib/active_job/enqueuing.rb
CHANGED
@@ -21,11 +21,13 @@ module ActiveJob
|
|
21
21
|
def perform_later(*args)
|
22
22
|
job_or_instantiate(*args).enqueue
|
23
23
|
end
|
24
|
+
ruby2_keywords(:perform_later) if respond_to?(:ruby2_keywords, true)
|
24
25
|
|
25
26
|
private
|
26
27
|
def job_or_instantiate(*args) # :doc:
|
27
28
|
args.first.is_a?(self) ? args.first : new(*args)
|
28
29
|
end
|
30
|
+
ruby2_keywords(:job_or_instantiate) if respond_to?(:ruby2_keywords, true)
|
29
31
|
end
|
30
32
|
|
31
33
|
# Enqueues the job to be performed by the queue adapter.
|
data/lib/active_job/execution.rb
CHANGED
@@ -18,13 +18,13 @@ module ActiveJob
|
|
18
18
|
# Rails.application.config.active_job.queue_adapter = :que
|
19
19
|
class QueAdapter
|
20
20
|
def enqueue(job) #:nodoc:
|
21
|
-
que_job = JobWrapper.enqueue job.serialize, priority: job.priority
|
21
|
+
que_job = JobWrapper.enqueue job.serialize, priority: job.priority, queue: job.queue_name
|
22
22
|
job.provider_job_id = que_job.attrs["job_id"]
|
23
23
|
que_job
|
24
24
|
end
|
25
25
|
|
26
26
|
def enqueue_at(job, timestamp) #:nodoc:
|
27
|
-
que_job = JobWrapper.enqueue job.serialize, priority: job.priority, run_at: Time.at(timestamp)
|
27
|
+
que_job = JobWrapper.enqueue job.serialize, priority: job.priority, queue: job.queue_name, run_at: Time.at(timestamp)
|
28
28
|
job.provider_job_id = que_job.attrs["job_id"]
|
29
29
|
que_job
|
30
30
|
end
|
@@ -26,28 +26,28 @@ module ActiveJob
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def enqueue(job) #:nodoc:
|
29
|
-
return if filtered?(job)
|
30
|
-
|
31
29
|
job_data = job_to_hash(job)
|
32
|
-
perform_or_enqueue(perform_enqueued_jobs, job, job_data)
|
30
|
+
perform_or_enqueue(perform_enqueued_jobs && !filtered?(job), job, job_data)
|
33
31
|
end
|
34
32
|
|
35
33
|
def enqueue_at(job, timestamp) #:nodoc:
|
36
|
-
return if filtered?(job)
|
37
|
-
|
38
34
|
job_data = job_to_hash(job, at: timestamp)
|
39
|
-
perform_or_enqueue(perform_enqueued_at_jobs, job, job_data)
|
35
|
+
perform_or_enqueue(perform_enqueued_at_jobs && !filtered?(job), job, job_data)
|
40
36
|
end
|
41
37
|
|
42
38
|
private
|
43
39
|
def job_to_hash(job, extras = {})
|
44
|
-
|
40
|
+
job.serialize.tap do |job_data|
|
41
|
+
job_data[:job] = job.class
|
42
|
+
job_data[:args] = job_data.fetch("arguments")
|
43
|
+
job_data[:queue] = job_data.fetch("queue_name")
|
44
|
+
end.merge(extras)
|
45
45
|
end
|
46
46
|
|
47
47
|
def perform_or_enqueue(perform, job, job_data)
|
48
48
|
if perform
|
49
49
|
performed_jobs << job_data
|
50
|
-
Base.execute
|
50
|
+
Base.execute(job.serialize)
|
51
51
|
else
|
52
52
|
enqueued_jobs << job_data
|
53
53
|
end
|
@@ -351,9 +351,21 @@ module ActiveJob
|
|
351
351
|
# assert_enqueued_with(job: MyJob, at: Date.tomorrow.noon)
|
352
352
|
# end
|
353
353
|
#
|
354
|
+
# The +at+ and +args+ arguments also accept a proc.
|
354
355
|
#
|
355
|
-
#
|
356
|
-
#
|
356
|
+
# To the +at+ proc, it will get passed the actual job's at argument.
|
357
|
+
#
|
358
|
+
# def test_assert_enqueued_with
|
359
|
+
# expected_time = ->(at) do
|
360
|
+
# (Date.yesterday..Date.tomorrow).cover?(at)
|
361
|
+
# end
|
362
|
+
#
|
363
|
+
# MyJob.set(at: Date.today.noon).perform_later
|
364
|
+
# assert_enqueued_with(job: MyJob, at: expected_time)
|
365
|
+
# end
|
366
|
+
#
|
367
|
+
# To the +args+ proc, it will get passed the actual job's arguments
|
368
|
+
# Your proc needs to return a boolean value determining if
|
357
369
|
# the job's arguments matches your expectation. This is useful to check only
|
358
370
|
# for a subset of arguments.
|
359
371
|
#
|
@@ -366,7 +378,6 @@ module ActiveJob
|
|
366
378
|
# assert_enqueued_with(job: MyJob, args: expected_args, queue: 'low')
|
367
379
|
# end
|
368
380
|
#
|
369
|
-
#
|
370
381
|
# If a block is passed, asserts that the block will cause the job to be
|
371
382
|
# enqueued with the given arguments.
|
372
383
|
#
|
@@ -425,8 +436,21 @@ module ActiveJob
|
|
425
436
|
# assert_performed_with(job: MyJob, at: Date.tomorrow.noon)
|
426
437
|
# end
|
427
438
|
#
|
428
|
-
# The +args+
|
429
|
-
#
|
439
|
+
# The +at+ and +args+ arguments also accept a proc.
|
440
|
+
#
|
441
|
+
# To the +at+ proc, it will get passed the actual job's at argument.
|
442
|
+
#
|
443
|
+
# def test_assert_enqueued_with
|
444
|
+
# expected_time = ->(at) do
|
445
|
+
# (Date.yesterday..Date.tomorrow).cover?(at)
|
446
|
+
# end
|
447
|
+
#
|
448
|
+
# MyJob.set(at: Date.today.noon).perform_later
|
449
|
+
# assert_enqueued_with(job: MyJob, at: expected_time)
|
450
|
+
# end
|
451
|
+
#
|
452
|
+
# To the +args+ proc, it will get passed the actual job's arguments
|
453
|
+
# Your proc needs to return a boolean value determining if
|
430
454
|
# the job's arguments matches your expectation. This is useful to check only
|
431
455
|
# for a subset of arguments.
|
432
456
|
#
|
@@ -630,7 +654,10 @@ module ActiveJob
|
|
630
654
|
|
631
655
|
def prepare_args_for_assertion(args)
|
632
656
|
args.dup.tap do |arguments|
|
633
|
-
arguments[:at]
|
657
|
+
if arguments[:at] && !arguments[:at].respond_to?(:call)
|
658
|
+
at_range = arguments[:at] - 1..arguments[:at] + 1
|
659
|
+
arguments[:at] = ->(at) { at_range.cover?(at) }
|
660
|
+
end
|
634
661
|
arguments[:args] = round_time_arguments(arguments[:args]) if arguments[:args]
|
635
662
|
end
|
636
663
|
end
|
@@ -650,16 +677,15 @@ module ActiveJob
|
|
650
677
|
|
651
678
|
def deserialize_args_for_assertion(job)
|
652
679
|
job.dup.tap do |new_job|
|
653
|
-
new_job[:at] =
|
680
|
+
new_job[:at] = Time.at(new_job[:at]) if new_job[:at]
|
654
681
|
new_job[:args] = ActiveJob::Arguments.deserialize(new_job[:args]) if new_job[:args]
|
655
682
|
end
|
656
683
|
end
|
657
684
|
|
658
685
|
def instantiate_job(payload)
|
659
|
-
|
660
|
-
job = payload[:job].new(*args)
|
686
|
+
job = payload[:job].deserialize(payload)
|
661
687
|
job.scheduled_at = Time.at(payload[:at]) if payload.key?(:at)
|
662
|
-
job.
|
688
|
+
job.send(:deserialize_arguments_if_needed)
|
663
689
|
job
|
664
690
|
end
|
665
691
|
|
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: 6.0.2
|
4
|
+
version: 6.0.3.2
|
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:
|
11
|
+
date: 2020-06-17 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: 6.0.2
|
19
|
+
version: 6.0.3.2
|
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: 6.0.2
|
26
|
+
version: 6.0.3.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: globalid
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,11 +95,11 @@ licenses:
|
|
95
95
|
- MIT
|
96
96
|
metadata:
|
97
97
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
98
|
-
changelog_uri: https://github.com/rails/rails/blob/v6.0.2
|
99
|
-
documentation_uri: https://api.rubyonrails.org/v6.0.2
|
100
|
-
mailing_list_uri: https://
|
101
|
-
source_code_uri: https://github.com/rails/rails/tree/v6.0.2
|
102
|
-
post_install_message:
|
98
|
+
changelog_uri: https://github.com/rails/rails/blob/v6.0.3.2/activejob/CHANGELOG.md
|
99
|
+
documentation_uri: https://api.rubyonrails.org/v6.0.3.2/
|
100
|
+
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
101
|
+
source_code_uri: https://github.com/rails/rails/tree/v6.0.3.2/activejob
|
102
|
+
post_install_message:
|
103
103
|
rdoc_options: []
|
104
104
|
require_paths:
|
105
105
|
- lib
|
@@ -114,8 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
|
-
rubygems_version: 3.
|
118
|
-
signing_key:
|
117
|
+
rubygems_version: 3.1.2
|
118
|
+
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Job framework with pluggable queues.
|
121
121
|
test_files: []
|