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
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "active_support/structured_event_subscriber"
|
|
4
|
+
|
|
5
|
+
module ActiveJob
|
|
6
|
+
class StructuredEventSubscriber < ActiveSupport::StructuredEventSubscriber # :nodoc:
|
|
7
|
+
def enqueue(event)
|
|
8
|
+
job = event.payload[:job]
|
|
9
|
+
adapter = event.payload[:adapter]
|
|
10
|
+
exception = event.payload[:exception_object] || job.enqueue_error
|
|
11
|
+
payload = {
|
|
12
|
+
job_class: job.class.name,
|
|
13
|
+
job_id: job.job_id,
|
|
14
|
+
queue: job.queue_name,
|
|
15
|
+
adapter: ActiveJob.adapter_name(adapter),
|
|
16
|
+
aborted: event.payload[:aborted],
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if exception
|
|
20
|
+
payload[:exception_class] = exception.class.name
|
|
21
|
+
payload[:exception_message] = exception.message
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
if job.class.log_arguments?
|
|
25
|
+
payload[:arguments] = job.arguments
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
emit_event("active_job.enqueued", payload)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def enqueue_at(event)
|
|
32
|
+
job = event.payload[:job]
|
|
33
|
+
adapter = event.payload[:adapter]
|
|
34
|
+
exception = event.payload[:exception_object] || job.enqueue_error
|
|
35
|
+
payload = {
|
|
36
|
+
job_class: job.class.name,
|
|
37
|
+
job_id: job.job_id,
|
|
38
|
+
queue: job.queue_name,
|
|
39
|
+
scheduled_at: job.scheduled_at,
|
|
40
|
+
adapter: ActiveJob.adapter_name(adapter),
|
|
41
|
+
aborted: event.payload[:aborted],
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if exception
|
|
45
|
+
payload[:exception_class] = exception.class.name
|
|
46
|
+
payload[:exception_message] = exception.message
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
if job.class.log_arguments?
|
|
50
|
+
payload[:arguments] = job.arguments
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
emit_event("active_job.enqueued_at", payload)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def enqueue_all(event)
|
|
57
|
+
jobs = event.payload[:jobs]
|
|
58
|
+
adapter = event.payload[:adapter]
|
|
59
|
+
enqueued_count = event.payload[:enqueued_count].to_i
|
|
60
|
+
failed_count = jobs.size - enqueued_count
|
|
61
|
+
|
|
62
|
+
emit_event("active_job.bulk_enqueued",
|
|
63
|
+
adapter: ActiveJob.adapter_name(adapter),
|
|
64
|
+
job_count: jobs.size,
|
|
65
|
+
enqueued_count: enqueued_count,
|
|
66
|
+
failed_enqueue_count: failed_count,
|
|
67
|
+
enqueued_classes: jobs.filter_map do |job|
|
|
68
|
+
job.class.name if jobs.count == enqueued_count || job.successfully_enqueued?
|
|
69
|
+
end.tally
|
|
70
|
+
)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def perform_start(event)
|
|
74
|
+
job = event.payload[:job]
|
|
75
|
+
payload = {
|
|
76
|
+
job_class: job.class.name,
|
|
77
|
+
job_id: job.job_id,
|
|
78
|
+
queue: job.queue_name,
|
|
79
|
+
enqueued_at: job.enqueued_at&.utc&.iso8601(9),
|
|
80
|
+
}
|
|
81
|
+
if job.class.log_arguments?
|
|
82
|
+
payload[:arguments] = job.arguments
|
|
83
|
+
end
|
|
84
|
+
emit_event("active_job.started", payload)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def perform(event)
|
|
88
|
+
job = event.payload[:job]
|
|
89
|
+
exception = event.payload[:exception_object]
|
|
90
|
+
adapter = event.payload[:adapter]
|
|
91
|
+
payload = {
|
|
92
|
+
job_class: job.class.name,
|
|
93
|
+
job_id: job.job_id,
|
|
94
|
+
queue: job.queue_name,
|
|
95
|
+
adapter: ActiveJob.adapter_name(adapter),
|
|
96
|
+
aborted: event.payload[:aborted],
|
|
97
|
+
duration: event.duration.round(2),
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if exception
|
|
101
|
+
payload[:exception_class] = exception.class.name
|
|
102
|
+
payload[:exception_message] = exception.message
|
|
103
|
+
payload[:exception_backtrace] = exception.backtrace
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
emit_event("active_job.completed", payload)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def enqueue_retry(event)
|
|
110
|
+
job = event.payload[:job]
|
|
111
|
+
exception = event.payload[:error]
|
|
112
|
+
wait = event.payload[:wait]
|
|
113
|
+
|
|
114
|
+
emit_event("active_job.retry_scheduled",
|
|
115
|
+
job_class: job.class.name,
|
|
116
|
+
job_id: job.job_id,
|
|
117
|
+
executions: job.executions,
|
|
118
|
+
wait_seconds: wait.to_i,
|
|
119
|
+
exception_class: exception&.class&.name,
|
|
120
|
+
exception_message: exception&.message
|
|
121
|
+
)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def retry_stopped(event)
|
|
125
|
+
job = event.payload[:job]
|
|
126
|
+
exception = event.payload[:error]
|
|
127
|
+
|
|
128
|
+
emit_event("active_job.retry_stopped",
|
|
129
|
+
job_class: job.class.name,
|
|
130
|
+
job_id: job.job_id,
|
|
131
|
+
executions: job.executions,
|
|
132
|
+
exception_class: exception.class.name,
|
|
133
|
+
exception_message: exception.message
|
|
134
|
+
)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def discard(event)
|
|
138
|
+
job = event.payload[:job]
|
|
139
|
+
exception = event.payload[:error]
|
|
140
|
+
|
|
141
|
+
emit_event("active_job.discarded",
|
|
142
|
+
job_class: job.class.name,
|
|
143
|
+
job_id: job.job_id,
|
|
144
|
+
exception_class: exception.class.name,
|
|
145
|
+
exception_message: exception.message
|
|
146
|
+
)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def interrupt(event)
|
|
150
|
+
job = event.payload[:job]
|
|
151
|
+
description = event.payload[:description]
|
|
152
|
+
reason = event.payload[:reason]
|
|
153
|
+
|
|
154
|
+
emit_event("active_job.interrupt",
|
|
155
|
+
job_class: job.class.name,
|
|
156
|
+
job_id: job.job_id,
|
|
157
|
+
description: description,
|
|
158
|
+
reason: reason,
|
|
159
|
+
)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def resume(event)
|
|
163
|
+
job = event.payload[:job]
|
|
164
|
+
description = event.payload[:description]
|
|
165
|
+
|
|
166
|
+
emit_event("active_job.resume",
|
|
167
|
+
job_class: job.class.name,
|
|
168
|
+
job_id: job.job_id,
|
|
169
|
+
description: description,
|
|
170
|
+
)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def step_skipped(event)
|
|
174
|
+
job = event.payload[:job]
|
|
175
|
+
step = event.payload[:step]
|
|
176
|
+
|
|
177
|
+
emit_event("active_job.step_skipped",
|
|
178
|
+
job_class: job.class.name,
|
|
179
|
+
job_id: job.job_id,
|
|
180
|
+
step: step.name,
|
|
181
|
+
)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def step_started(event)
|
|
185
|
+
job = event.payload[:job]
|
|
186
|
+
step = event.payload[:step]
|
|
187
|
+
|
|
188
|
+
emit_event("active_job.step_started",
|
|
189
|
+
job_class: job.class.name,
|
|
190
|
+
job_id: job.job_id,
|
|
191
|
+
step: step.name,
|
|
192
|
+
cursor: step.cursor,
|
|
193
|
+
resumed: step.resumed?,
|
|
194
|
+
)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def step(event)
|
|
198
|
+
job = event.payload[:job]
|
|
199
|
+
step = event.payload[:step]
|
|
200
|
+
exception = event.payload[:exception_object]
|
|
201
|
+
payload = {
|
|
202
|
+
job_class: job.class.name,
|
|
203
|
+
job_id: job.job_id,
|
|
204
|
+
step: step.name,
|
|
205
|
+
cursor: step.cursor,
|
|
206
|
+
interrupted: event.payload[:interrupted],
|
|
207
|
+
duration: event.duration.round(2),
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if exception
|
|
211
|
+
payload[:exception_class] = exception.class.name
|
|
212
|
+
payload[:exception_message] = exception.message
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
emit_event("active_job.step", payload)
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
ActiveJob::StructuredEventSubscriber.attach_to :active_job
|
|
@@ -39,10 +39,13 @@ module ActiveJob
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def before_setup # :nodoc:
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
queue_adapter_specific_to_this_test_class = queue_adapter_for_test
|
|
44
43
|
queue_adapter_changed_jobs.each do |klass|
|
|
45
|
-
|
|
44
|
+
if queue_adapter_specific_to_this_test_class
|
|
45
|
+
klass.enable_test_adapter(queue_adapter_specific_to_this_test_class)
|
|
46
|
+
elsif klass._queue_adapter.nil?
|
|
47
|
+
klass.enable_test_adapter(ActiveJob::QueueAdapters::TestAdapter.new)
|
|
48
|
+
end
|
|
46
49
|
end
|
|
47
50
|
|
|
48
51
|
clear_enqueued_jobs
|
|
@@ -61,7 +64,6 @@ module ActiveJob
|
|
|
61
64
|
# Override this method to specify a different adapter. The adapter must
|
|
62
65
|
# implement the same interface as ActiveJob::QueueAdapters::TestAdapter.
|
|
63
66
|
def queue_adapter_for_test
|
|
64
|
-
ActiveJob::QueueAdapters::TestAdapter.new
|
|
65
67
|
end
|
|
66
68
|
|
|
67
69
|
# Asserts that the number of enqueued jobs matches the given number.
|
|
@@ -118,6 +120,8 @@ module ActiveJob
|
|
|
118
120
|
# end
|
|
119
121
|
# end
|
|
120
122
|
def assert_enqueued_jobs(number, only: nil, except: nil, queue: nil, &block)
|
|
123
|
+
require_active_job_test_adapter!("assert_enqueued_jobs")
|
|
124
|
+
|
|
121
125
|
if block_given?
|
|
122
126
|
original_jobs = enqueued_jobs_with(only: only, except: except, queue: queue)
|
|
123
127
|
|
|
@@ -180,6 +184,8 @@ module ActiveJob
|
|
|
180
184
|
#
|
|
181
185
|
# assert_enqueued_jobs 0, &block
|
|
182
186
|
def assert_no_enqueued_jobs(only: nil, except: nil, queue: nil, &block)
|
|
187
|
+
require_active_job_test_adapter!("assert_no_enqueued_jobs")
|
|
188
|
+
|
|
183
189
|
assert_enqueued_jobs 0, only: only, except: except, queue: queue, &block
|
|
184
190
|
end
|
|
185
191
|
|
|
@@ -270,6 +276,8 @@ module ActiveJob
|
|
|
270
276
|
# end
|
|
271
277
|
# end
|
|
272
278
|
def assert_performed_jobs(number, only: nil, except: nil, queue: nil, &block)
|
|
279
|
+
require_active_job_test_adapter!("assert_performed_jobs")
|
|
280
|
+
|
|
273
281
|
if block_given?
|
|
274
282
|
original_count = performed_jobs.size
|
|
275
283
|
|
|
@@ -338,6 +346,8 @@ module ActiveJob
|
|
|
338
346
|
#
|
|
339
347
|
# assert_performed_jobs 0, &block
|
|
340
348
|
def assert_no_performed_jobs(only: nil, except: nil, queue: nil, &block)
|
|
349
|
+
require_active_job_test_adapter!("assert_no_performed_jobs")
|
|
350
|
+
|
|
341
351
|
assert_performed_jobs 0, only: only, except: except, queue: queue, &block
|
|
342
352
|
end
|
|
343
353
|
|
|
@@ -394,6 +404,8 @@ module ActiveJob
|
|
|
394
404
|
# end
|
|
395
405
|
# end
|
|
396
406
|
def assert_enqueued_with(job: nil, args: nil, at: nil, queue: nil, priority: nil, &block)
|
|
407
|
+
require_active_job_test_adapter!("assert_enqueued_with")
|
|
408
|
+
|
|
397
409
|
expected = { job: job, args: args, at: at, queue: queue, priority: priority }.compact
|
|
398
410
|
expected_args = prepare_args_for_assertion(expected)
|
|
399
411
|
potential_matches = []
|
|
@@ -496,6 +508,8 @@ module ActiveJob
|
|
|
496
508
|
# end
|
|
497
509
|
# end
|
|
498
510
|
def assert_performed_with(job: nil, args: nil, at: nil, queue: nil, priority: nil, &block)
|
|
511
|
+
require_active_job_test_adapter!("assert_performed_with")
|
|
512
|
+
|
|
499
513
|
expected = { job: job, args: args, at: at, queue: queue, priority: priority }.compact
|
|
500
514
|
expected_args = prepare_args_for_assertion(expected)
|
|
501
515
|
potential_matches = []
|
|
@@ -604,7 +618,10 @@ module ActiveJob
|
|
|
604
618
|
# If queue_adapter_for_test is overridden to return a different adapter,
|
|
605
619
|
# +perform_enqueued_jobs+ will merely execute the block.
|
|
606
620
|
def perform_enqueued_jobs(only: nil, except: nil, queue: nil, at: nil, &block)
|
|
607
|
-
|
|
621
|
+
unless block_given?
|
|
622
|
+
require_active_job_test_adapter!("perform_enqueued_jobs (without a block)")
|
|
623
|
+
return flush_enqueued_jobs(only: only, except: except, queue: queue, at: at)
|
|
624
|
+
end
|
|
608
625
|
|
|
609
626
|
return _assert_nothing_raised_or_warn("perform_enqueued_jobs", &block) unless using_test_adapter?
|
|
610
627
|
|
|
@@ -646,6 +663,12 @@ module ActiveJob
|
|
|
646
663
|
end
|
|
647
664
|
|
|
648
665
|
private
|
|
666
|
+
def require_active_job_test_adapter!(method)
|
|
667
|
+
unless using_test_adapter?
|
|
668
|
+
raise ArgumentError.new("#{method} requires the Active Job test adapter, you're using #{queue_adapter.class.name}.")
|
|
669
|
+
end
|
|
670
|
+
end
|
|
671
|
+
|
|
649
672
|
def using_test_adapter?
|
|
650
673
|
queue_adapter.is_a?(ActiveJob::QueueAdapters::TestAdapter)
|
|
651
674
|
end
|
data/lib/active_job.rb
CHANGED
|
@@ -39,8 +39,12 @@ module ActiveJob
|
|
|
39
39
|
autoload :Arguments
|
|
40
40
|
autoload :DeserializationError, "active_job/arguments"
|
|
41
41
|
autoload :SerializationError, "active_job/arguments"
|
|
42
|
+
autoload :UnknownJobClassError, "active_job/core"
|
|
43
|
+
autoload :EnqueueAfterTransactionCommit
|
|
42
44
|
|
|
43
45
|
eager_autoload do
|
|
46
|
+
autoload :Continuable
|
|
47
|
+
autoload :Continuation
|
|
44
48
|
autoload :Serializers
|
|
45
49
|
autoload :ConfiguredJob
|
|
46
50
|
end
|
|
@@ -49,15 +53,7 @@ module ActiveJob
|
|
|
49
53
|
autoload :TestHelper
|
|
50
54
|
|
|
51
55
|
##
|
|
52
|
-
# :singleton-method:
|
|
53
|
-
# If false, \Rails will preserve the legacy serialization of BigDecimal job arguments as Strings.
|
|
54
|
-
# If true, \Rails will use the new BigDecimalSerializer to (de)serialize BigDecimal losslessly.
|
|
55
|
-
# Legacy serialization will be removed in \Rails 7.2, along with this config.
|
|
56
|
-
singleton_class.attr_accessor :use_big_decimal_serializer
|
|
57
|
-
self.use_big_decimal_serializer = false
|
|
58
|
-
|
|
59
|
-
##
|
|
60
|
-
# :singleton-method:
|
|
56
|
+
# :singleton-method: verbose_enqueue_logs
|
|
61
57
|
#
|
|
62
58
|
# Specifies if the methods calling background job enqueue should be logged below
|
|
63
59
|
# their relevant enqueue log lines. Defaults to false.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activejob
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 8.1.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Heinemeier Hansson
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version:
|
|
18
|
+
version: 8.1.2.1
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version:
|
|
25
|
+
version: 8.1.2.1
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: globalid
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -51,17 +51,25 @@ files:
|
|
|
51
51
|
- lib/active_job/base.rb
|
|
52
52
|
- lib/active_job/callbacks.rb
|
|
53
53
|
- lib/active_job/configured_job.rb
|
|
54
|
+
- lib/active_job/continuable.rb
|
|
55
|
+
- lib/active_job/continuation.rb
|
|
56
|
+
- lib/active_job/continuation/step.rb
|
|
57
|
+
- lib/active_job/continuation/test_helper.rb
|
|
58
|
+
- lib/active_job/continuation/validation.rb
|
|
54
59
|
- lib/active_job/core.rb
|
|
55
60
|
- lib/active_job/deprecator.rb
|
|
61
|
+
- lib/active_job/enqueue_after_transaction_commit.rb
|
|
56
62
|
- lib/active_job/enqueuing.rb
|
|
57
63
|
- lib/active_job/exceptions.rb
|
|
58
64
|
- lib/active_job/execution.rb
|
|
65
|
+
- lib/active_job/execution_state.rb
|
|
59
66
|
- lib/active_job/gem_version.rb
|
|
60
67
|
- lib/active_job/instrumentation.rb
|
|
61
68
|
- lib/active_job/log_subscriber.rb
|
|
62
69
|
- lib/active_job/logging.rb
|
|
63
70
|
- lib/active_job/queue_adapter.rb
|
|
64
71
|
- lib/active_job/queue_adapters.rb
|
|
72
|
+
- lib/active_job/queue_adapters/abstract_adapter.rb
|
|
65
73
|
- lib/active_job/queue_adapters/async_adapter.rb
|
|
66
74
|
- lib/active_job/queue_adapters/backburner_adapter.rb
|
|
67
75
|
- lib/active_job/queue_adapters/delayed_job_adapter.rb
|
|
@@ -70,12 +78,12 @@ files:
|
|
|
70
78
|
- lib/active_job/queue_adapters/resque_adapter.rb
|
|
71
79
|
- lib/active_job/queue_adapters/sidekiq_adapter.rb
|
|
72
80
|
- lib/active_job/queue_adapters/sneakers_adapter.rb
|
|
73
|
-
- lib/active_job/queue_adapters/sucker_punch_adapter.rb
|
|
74
81
|
- lib/active_job/queue_adapters/test_adapter.rb
|
|
75
82
|
- lib/active_job/queue_name.rb
|
|
76
83
|
- lib/active_job/queue_priority.rb
|
|
77
84
|
- lib/active_job/railtie.rb
|
|
78
85
|
- lib/active_job/serializers.rb
|
|
86
|
+
- lib/active_job/serializers/action_controller_parameters_serializer.rb
|
|
79
87
|
- lib/active_job/serializers/big_decimal_serializer.rb
|
|
80
88
|
- lib/active_job/serializers/date_serializer.rb
|
|
81
89
|
- lib/active_job/serializers/date_time_serializer.rb
|
|
@@ -87,10 +95,9 @@ files:
|
|
|
87
95
|
- lib/active_job/serializers/time_object_serializer.rb
|
|
88
96
|
- lib/active_job/serializers/time_serializer.rb
|
|
89
97
|
- lib/active_job/serializers/time_with_zone_serializer.rb
|
|
98
|
+
- lib/active_job/structured_event_subscriber.rb
|
|
90
99
|
- lib/active_job/test_case.rb
|
|
91
100
|
- lib/active_job/test_helper.rb
|
|
92
|
-
- lib/active_job/timezones.rb
|
|
93
|
-
- lib/active_job/translation.rb
|
|
94
101
|
- lib/active_job/version.rb
|
|
95
102
|
- lib/rails/generators/job/USAGE
|
|
96
103
|
- lib/rails/generators/job/job_generator.rb
|
|
@@ -101,10 +108,10 @@ licenses:
|
|
|
101
108
|
- MIT
|
|
102
109
|
metadata:
|
|
103
110
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
|
104
|
-
changelog_uri: https://github.com/rails/rails/blob/
|
|
105
|
-
documentation_uri: https://api.rubyonrails.org/
|
|
111
|
+
changelog_uri: https://github.com/rails/rails/blob/v8.1.2.1/activejob/CHANGELOG.md
|
|
112
|
+
documentation_uri: https://api.rubyonrails.org/v8.1.2.1/
|
|
106
113
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
|
107
|
-
source_code_uri: https://github.com/rails/rails/tree/
|
|
114
|
+
source_code_uri: https://github.com/rails/rails/tree/v8.1.2.1/activejob
|
|
108
115
|
rubygems_mfa_required: 'true'
|
|
109
116
|
rdoc_options: []
|
|
110
117
|
require_paths:
|
|
@@ -113,14 +120,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
113
120
|
requirements:
|
|
114
121
|
- - ">="
|
|
115
122
|
- !ruby/object:Gem::Version
|
|
116
|
-
version: 2.
|
|
123
|
+
version: 3.2.0
|
|
117
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
125
|
requirements:
|
|
119
126
|
- - ">="
|
|
120
127
|
- !ruby/object:Gem::Version
|
|
121
128
|
version: '0'
|
|
122
129
|
requirements: []
|
|
123
|
-
rubygems_version:
|
|
130
|
+
rubygems_version: 4.0.6
|
|
124
131
|
specification_version: 4
|
|
125
132
|
summary: Job framework with pluggable queues.
|
|
126
133
|
test_files: []
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "sucker_punch"
|
|
4
|
-
|
|
5
|
-
module ActiveJob
|
|
6
|
-
module QueueAdapters
|
|
7
|
-
# = Sucker Punch adapter for Active Job
|
|
8
|
-
#
|
|
9
|
-
# Sucker Punch is a single-process Ruby asynchronous processing library.
|
|
10
|
-
# This reduces the cost of hosting on a service like Heroku along
|
|
11
|
-
# with the memory footprint of having to maintain additional jobs if
|
|
12
|
-
# hosting on a dedicated server. All queues can run within a
|
|
13
|
-
# single application (e.g. \Rails, Sinatra, etc.) process.
|
|
14
|
-
#
|
|
15
|
-
# Read more about Sucker Punch {here}[https://github.com/brandonhilkert/sucker_punch].
|
|
16
|
-
#
|
|
17
|
-
# To use Sucker Punch set the queue_adapter config to +:sucker_punch+.
|
|
18
|
-
#
|
|
19
|
-
# Rails.application.config.active_job.queue_adapter = :sucker_punch
|
|
20
|
-
class SuckerPunchAdapter
|
|
21
|
-
def enqueue(job) # :nodoc:
|
|
22
|
-
if JobWrapper.respond_to?(:perform_async)
|
|
23
|
-
# sucker_punch 2.0 API
|
|
24
|
-
JobWrapper.perform_async job.serialize
|
|
25
|
-
else
|
|
26
|
-
# sucker_punch 1.0 API
|
|
27
|
-
JobWrapper.new.async.perform job.serialize
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def enqueue_at(job, timestamp) # :nodoc:
|
|
32
|
-
if JobWrapper.respond_to?(:perform_in)
|
|
33
|
-
delay = timestamp - Time.current.to_f
|
|
34
|
-
JobWrapper.perform_in delay, job.serialize
|
|
35
|
-
else
|
|
36
|
-
raise NotImplementedError, "sucker_punch 1.0 does not support `enqueue_at`. Please upgrade to version ~> 2.0.0 to enable this behavior."
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
class JobWrapper # :nodoc:
|
|
41
|
-
include SuckerPunch::Job
|
|
42
|
-
|
|
43
|
-
def perform(job_data)
|
|
44
|
-
Base.execute job_data
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
data/lib/active_job/timezones.rb
DELETED