activejob 8.0.2 → 8.1.0.beta1
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 +63 -25
- data/README.md +8 -6
- data/lib/active_job/arguments.rb +46 -47
- data/lib/active_job/base.rb +4 -6
- 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 +12 -2
- data/lib/active_job/enqueue_after_transaction_commit.rb +1 -26
- data/lib/active_job/enqueuing.rb +8 -4
- data/lib/active_job/exceptions.rb +16 -6
- 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 +61 -6
- data/lib/active_job/queue_adapters/abstract_adapter.rb +6 -0
- data/lib/active_job/queue_adapters/async_adapter.rb +5 -1
- data/lib/active_job/queue_adapters/sidekiq_adapter.rb +19 -0
- data/lib/active_job/queue_adapters/test_adapter.rb +5 -1
- data/lib/active_job/railtie.rb +9 -19
- 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 +11 -13
- 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 +46 -15
- data/lib/active_job.rb +2 -0
- metadata +15 -11
- data/lib/active_job/queue_adapters/sucker_punch_adapter.rb +0 -56
- data/lib/active_job/timezones.rb +0 -13
- data/lib/active_job/translation.rb +0 -13
@@ -18,6 +18,25 @@ module ActiveJob
|
|
18
18
|
#
|
19
19
|
# Rails.application.config.active_job.queue_adapter = :sidekiq
|
20
20
|
class SidekiqAdapter < AbstractAdapter
|
21
|
+
def initialize(*) # :nodoc:
|
22
|
+
@stopping = false
|
23
|
+
|
24
|
+
Sidekiq.configure_server do |config|
|
25
|
+
config.on(:quiet) { @stopping = true }
|
26
|
+
end
|
27
|
+
|
28
|
+
Sidekiq.configure_client do |config|
|
29
|
+
config.on(:quiet) { @stopping = true }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def check_adapter
|
34
|
+
ActiveJob.deprecator.warn <<~MSG.squish
|
35
|
+
The built-in `sidekiq` adapter is deprecated and will be removed in Rails 8.2.
|
36
|
+
Please upgrade `sidekiq` gem to version 7.3.3 or later to use the `sidekiq` gem's adapter.
|
37
|
+
MSG
|
38
|
+
end
|
39
|
+
|
21
40
|
def enqueue(job) # :nodoc:
|
22
41
|
job.provider_job_id = JobWrapper.set(
|
23
42
|
wrapped: job.class,
|
@@ -12,7 +12,7 @@ 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, :stopping)
|
16
16
|
attr_writer(:enqueued_jobs, :performed_jobs)
|
17
17
|
|
18
18
|
# Provides a store of all the enqueued jobs with the TestAdapter so you can check them.
|
@@ -35,6 +35,10 @@ module ActiveJob
|
|
35
35
|
perform_or_enqueue(perform_enqueued_at_jobs && !filtered?(job), job, job_data)
|
36
36
|
end
|
37
37
|
|
38
|
+
def stopping?
|
39
|
+
@stopping.is_a?(Proc) ? @stopping.call : @stopping
|
40
|
+
end
|
41
|
+
|
38
42
|
private
|
39
43
|
def job_to_hash(job, extras = {})
|
40
44
|
job.serialize.tap do |job_data|
|
data/lib/active_job/railtie.rb
CHANGED
@@ -19,7 +19,7 @@ module ActiveJob
|
|
19
19
|
end
|
20
20
|
|
21
21
|
initializer "active_job.custom_serializers" do |app|
|
22
|
-
|
22
|
+
ActiveSupport.on_load(:active_job) do
|
23
23
|
custom_serializers = app.config.active_job.custom_serializers
|
24
24
|
ActiveJob::Serializers.add_serializers custom_serializers
|
25
25
|
end
|
@@ -29,25 +29,14 @@ module ActiveJob
|
|
29
29
|
ActiveSupport.on_load(:active_job) do
|
30
30
|
ActiveSupport.on_load(:active_record) do
|
31
31
|
ActiveJob::Base.include EnqueueAfterTransactionCommit
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
50
|
-
end
|
36
|
+
initializer "active_job.action_controller_parameters" do |app|
|
37
|
+
ActiveSupport.on_load(:active_job) do
|
38
|
+
ActiveSupport.on_load(:action_controller) do
|
39
|
+
ActiveJob::Serializers.add_serializers ActiveJob::Serializers::ActionControllerParametersSerializer
|
51
40
|
end
|
52
41
|
end
|
53
42
|
end
|
@@ -70,6 +59,7 @@ module ActiveJob
|
|
70
59
|
options = options.except(
|
71
60
|
:log_query_tags_around_perform,
|
72
61
|
:custom_serializers,
|
62
|
+
# This config can't be applied globally, so we need to remove otherwise it will be applied to `ActiveJob::Base`.
|
73
63
|
:enqueue_after_transaction_commit
|
74
64
|
)
|
75
65
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveJob
|
4
|
+
module Serializers
|
5
|
+
class ActionControllerParametersSerializer < ObjectSerializer
|
6
|
+
def serialize(argument)
|
7
|
+
Arguments.serialize(argument.to_h.with_indifferent_access)
|
8
|
+
end
|
9
|
+
|
10
|
+
def deserialize(hash)
|
11
|
+
raise NotImplementedError # Serialized as a HashWithIndifferentAccess
|
12
|
+
end
|
13
|
+
|
14
|
+
def serialize?(argument)
|
15
|
+
argument.respond_to?(:permitted?) && argument.respond_to?(:to_h)
|
16
|
+
end
|
17
|
+
|
18
|
+
def klass
|
19
|
+
if defined?(ActionController::Parameters)
|
20
|
+
ActionController::Parameters
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -6,20 +6,19 @@ module ActiveJob
|
|
6
6
|
def serialize(duration)
|
7
7
|
# Ideally duration.parts would be wrapped in an array before passing to Arguments.serialize,
|
8
8
|
# but we continue passing the bare hash for backwards compatibility:
|
9
|
-
super("value" => duration.value, "parts" => Arguments.serialize(duration.parts))
|
9
|
+
super("value" => duration.value, "parts" => Arguments.serialize(duration.parts.to_a))
|
10
10
|
end
|
11
11
|
|
12
12
|
def deserialize(hash)
|
13
13
|
value = hash["value"]
|
14
|
-
parts = Arguments.deserialize(hash["parts"])
|
14
|
+
parts = Arguments.deserialize(hash["parts"].to_h)
|
15
15
|
# `parts` is originally a hash, but will have been flattened to an array by Arguments.serialize
|
16
16
|
klass.new(value, parts.to_h)
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
19
|
+
def klass
|
20
|
+
ActiveSupport::Duration
|
21
|
+
end
|
23
22
|
end
|
24
23
|
end
|
25
24
|
end
|
@@ -17,11 +17,9 @@ module ActiveJob
|
|
17
17
|
# Money.new(hash["amount"], hash["currency"])
|
18
18
|
# end
|
19
19
|
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# Money
|
24
|
-
# end
|
20
|
+
# def klass
|
21
|
+
# Money
|
22
|
+
# end
|
25
23
|
# end
|
26
24
|
class ObjectSerializer
|
27
25
|
include Singleton
|
@@ -37,19 +35,19 @@ module ActiveJob
|
|
37
35
|
|
38
36
|
# Serializes an argument to a JSON primitive type.
|
39
37
|
def serialize(hash)
|
40
|
-
|
38
|
+
hash[Arguments::OBJECT_SERIALIZER_KEY] = self.class.name
|
39
|
+
hash
|
41
40
|
end
|
42
41
|
|
43
42
|
# Deserializes an argument from a JSON primitive type.
|
44
|
-
def deserialize(
|
45
|
-
raise NotImplementedError
|
43
|
+
def deserialize(hash)
|
44
|
+
raise NotImplementedError, "#{self.class.name} should implement a public #deserialize(hash) method"
|
46
45
|
end
|
47
46
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
47
|
+
# The class of the object that will be serialized.
|
48
|
+
def klass
|
49
|
+
raise NotImplementedError, "#{self.class.name} should implement a public #klass method"
|
50
|
+
end
|
53
51
|
end
|
54
52
|
end
|
55
53
|
end
|
@@ -3,21 +3,21 @@
|
|
3
3
|
module ActiveJob
|
4
4
|
module Serializers
|
5
5
|
class RangeSerializer < ObjectSerializer
|
6
|
-
KEYS = %w[begin end exclude_end].freeze
|
7
|
-
|
8
6
|
def serialize(range)
|
9
|
-
|
10
|
-
|
7
|
+
super(
|
8
|
+
"begin" => Arguments.serialize(range.begin),
|
9
|
+
"end" => Arguments.serialize(range.end),
|
10
|
+
"exclude_end" => range.exclude_end?, # Always boolean, no need to serialize
|
11
|
+
)
|
11
12
|
end
|
12
13
|
|
13
14
|
def deserialize(hash)
|
14
|
-
|
15
|
+
Range.new(*Arguments.deserialize([hash["begin"], hash["end"]]), hash["exclude_end"])
|
15
16
|
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
18
|
+
def klass
|
19
|
+
::Range
|
20
|
+
end
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -4,17 +4,16 @@ module ActiveJob
|
|
4
4
|
module Serializers
|
5
5
|
class SymbolSerializer < ObjectSerializer # :nodoc:
|
6
6
|
def serialize(argument)
|
7
|
-
super("value" => argument.
|
7
|
+
super("value" => argument.name)
|
8
8
|
end
|
9
9
|
|
10
10
|
def deserialize(argument)
|
11
11
|
argument["value"].to_sym
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
14
|
+
def klass
|
15
|
+
Symbol
|
16
|
+
end
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
@@ -19,16 +19,17 @@ module ActiveJob
|
|
19
19
|
autoload :ModuleSerializer
|
20
20
|
autoload :RangeSerializer
|
21
21
|
autoload :BigDecimalSerializer
|
22
|
+
autoload :ActionControllerParametersSerializer
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
@serializers = Set.new
|
25
|
+
@serializers_index = {}
|
25
26
|
|
26
27
|
class << self
|
27
28
|
# Returns serialized representative of the passed object.
|
28
29
|
# Will look up through all known serializers.
|
29
30
|
# Raises ActiveJob::SerializationError if it can't find a proper serializer.
|
30
31
|
def serialize(argument)
|
31
|
-
serializer = serializers.
|
32
|
+
serializer = @serializers_index[argument.class] || serializers.find { |s| s.serialize?(argument) }
|
32
33
|
raise SerializationError.new("Unsupported argument type: #{argument.class.name}") unless serializer
|
33
34
|
serializer.serialize(argument)
|
34
35
|
end
|
@@ -47,24 +48,54 @@ module ActiveJob
|
|
47
48
|
end
|
48
49
|
|
49
50
|
# Returns list of known serializers.
|
50
|
-
|
51
|
-
|
51
|
+
attr_reader :serializers
|
52
|
+
|
53
|
+
def serializers=(serializers)
|
54
|
+
@serializers = serializers
|
55
|
+
index_serializers
|
52
56
|
end
|
53
57
|
|
54
58
|
# Adds new serializers to a list of known serializers.
|
55
59
|
def add_serializers(*new_serializers)
|
56
|
-
|
60
|
+
new_serializers = new_serializers.flatten
|
61
|
+
new_serializers.map! do |s|
|
62
|
+
if s.is_a?(Class) && s < ObjectSerializer
|
63
|
+
s.instance
|
64
|
+
else
|
65
|
+
s
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
@serializers += new_serializers
|
70
|
+
index_serializers
|
71
|
+
@serializers
|
57
72
|
end
|
73
|
+
|
74
|
+
private
|
75
|
+
def index_serializers
|
76
|
+
@serializers_index.clear
|
77
|
+
serializers.each do |s|
|
78
|
+
if s.respond_to?(:klass)
|
79
|
+
@serializers_index[s.klass] = s
|
80
|
+
elsif s.respond_to?(:klass, true)
|
81
|
+
klass = s.send(:klass)
|
82
|
+
ActiveJob.deprecator.warn(<<~MSG.squish)
|
83
|
+
#{s.class.name}#klass method should be public.
|
84
|
+
MSG
|
85
|
+
@serializers_index[klass] = s
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
58
89
|
end
|
59
90
|
|
60
|
-
add_serializers SymbolSerializer,
|
61
|
-
DurationSerializer,
|
62
|
-
DateTimeSerializer,
|
63
|
-
DateSerializer,
|
64
|
-
TimeWithZoneSerializer,
|
65
|
-
TimeSerializer,
|
66
|
-
ModuleSerializer,
|
67
|
-
RangeSerializer,
|
68
|
-
BigDecimalSerializer
|
91
|
+
add_serializers SymbolSerializer.instance,
|
92
|
+
DurationSerializer.instance,
|
93
|
+
DateTimeSerializer.instance,
|
94
|
+
DateSerializer.instance,
|
95
|
+
TimeWithZoneSerializer.instance,
|
96
|
+
TimeSerializer.instance,
|
97
|
+
ModuleSerializer.instance,
|
98
|
+
RangeSerializer.instance,
|
99
|
+
BigDecimalSerializer.instance
|
69
100
|
end
|
70
101
|
end
|
data/lib/active_job.rb
CHANGED
@@ -39,9 +39,11 @@ 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"
|
42
43
|
autoload :EnqueueAfterTransactionCommit
|
43
44
|
|
44
45
|
eager_autoload do
|
46
|
+
autoload :Continuation
|
45
47
|
autoload :Serializers
|
46
48
|
autoload :ConfiguredJob
|
47
49
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activejob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.0.
|
4
|
+
version: 8.1.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activesupport
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - '='
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 8.0.
|
18
|
+
version: 8.1.0.beta1
|
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: 8.0.
|
25
|
+
version: 8.1.0.beta1
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: globalid
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,12 +51,18 @@ 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
|
56
61
|
- lib/active_job/enqueue_after_transaction_commit.rb
|
57
62
|
- lib/active_job/enqueuing.rb
|
58
63
|
- lib/active_job/exceptions.rb
|
59
64
|
- lib/active_job/execution.rb
|
65
|
+
- lib/active_job/execution_state.rb
|
60
66
|
- lib/active_job/gem_version.rb
|
61
67
|
- lib/active_job/instrumentation.rb
|
62
68
|
- lib/active_job/log_subscriber.rb
|
@@ -72,12 +78,12 @@ files:
|
|
72
78
|
- lib/active_job/queue_adapters/resque_adapter.rb
|
73
79
|
- lib/active_job/queue_adapters/sidekiq_adapter.rb
|
74
80
|
- lib/active_job/queue_adapters/sneakers_adapter.rb
|
75
|
-
- lib/active_job/queue_adapters/sucker_punch_adapter.rb
|
76
81
|
- lib/active_job/queue_adapters/test_adapter.rb
|
77
82
|
- lib/active_job/queue_name.rb
|
78
83
|
- lib/active_job/queue_priority.rb
|
79
84
|
- lib/active_job/railtie.rb
|
80
85
|
- lib/active_job/serializers.rb
|
86
|
+
- lib/active_job/serializers/action_controller_parameters_serializer.rb
|
81
87
|
- lib/active_job/serializers/big_decimal_serializer.rb
|
82
88
|
- lib/active_job/serializers/date_serializer.rb
|
83
89
|
- lib/active_job/serializers/date_time_serializer.rb
|
@@ -91,8 +97,6 @@ files:
|
|
91
97
|
- lib/active_job/serializers/time_with_zone_serializer.rb
|
92
98
|
- lib/active_job/test_case.rb
|
93
99
|
- lib/active_job/test_helper.rb
|
94
|
-
- lib/active_job/timezones.rb
|
95
|
-
- lib/active_job/translation.rb
|
96
100
|
- lib/active_job/version.rb
|
97
101
|
- lib/rails/generators/job/USAGE
|
98
102
|
- lib/rails/generators/job/job_generator.rb
|
@@ -103,10 +107,10 @@ licenses:
|
|
103
107
|
- MIT
|
104
108
|
metadata:
|
105
109
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
106
|
-
changelog_uri: https://github.com/rails/rails/blob/v8.0.
|
107
|
-
documentation_uri: https://api.rubyonrails.org/v8.0.
|
110
|
+
changelog_uri: https://github.com/rails/rails/blob/v8.1.0.beta1/activejob/CHANGELOG.md
|
111
|
+
documentation_uri: https://api.rubyonrails.org/v8.1.0.beta1/
|
108
112
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
109
|
-
source_code_uri: https://github.com/rails/rails/tree/v8.0.
|
113
|
+
source_code_uri: https://github.com/rails/rails/tree/v8.1.0.beta1/activejob
|
110
114
|
rubygems_mfa_required: 'true'
|
111
115
|
rdoc_options: []
|
112
116
|
require_paths:
|
@@ -122,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
126
|
- !ruby/object:Gem::Version
|
123
127
|
version: '0'
|
124
128
|
requirements: []
|
125
|
-
rubygems_version: 3.6.
|
129
|
+
rubygems_version: 3.6.9
|
126
130
|
specification_version: 4
|
127
131
|
summary: Job framework with pluggable queues.
|
128
132
|
test_files: []
|
@@ -1,56 +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 < 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
|
-
|
28
|
-
def enqueue(job) # :nodoc:
|
29
|
-
if JobWrapper.respond_to?(:perform_async)
|
30
|
-
# sucker_punch 2.0 API
|
31
|
-
JobWrapper.perform_async job.serialize
|
32
|
-
else
|
33
|
-
# sucker_punch 1.0 API
|
34
|
-
JobWrapper.new.async.perform job.serialize
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def enqueue_at(job, timestamp) # :nodoc:
|
39
|
-
if JobWrapper.respond_to?(:perform_in)
|
40
|
-
delay = timestamp - Time.current.to_f
|
41
|
-
JobWrapper.perform_in delay, job.serialize
|
42
|
-
else
|
43
|
-
raise NotImplementedError, "sucker_punch 1.0 does not support `enqueue_at`. Please upgrade to version ~> 2.0.0 to enable this behavior."
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
class JobWrapper # :nodoc:
|
48
|
-
include SuckerPunch::Job
|
49
|
-
|
50
|
-
def perform(job_data)
|
51
|
-
Base.execute job_data
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
data/lib/active_job/timezones.rb
DELETED