acidic_job 1.0.0.pre16 → 1.0.0.pre17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/acidic_job/extensions/sidekiq.rb +5 -1
- data/lib/acidic_job/step.rb +16 -1
- data/lib/acidic_job/version.rb +1 -1
- data/lib/acidic_job.rb +4 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c458faa1225d1b5e0fe7590bdd00371169de92b638dfbc74e88958b2430c5c7e
|
4
|
+
data.tar.gz: 8657eea5fd2a3929d049be9a7da1a252413cab1de42b991178673328202f4ee1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ae6d08046b2bc2e3388544fa61f308cf57c9dab5a4f67a923d1400ca7743fb48966a9aa0ce504a2d16d5c7e80fc98d8fd5308583236ff305ffb0d1b2eb17c70
|
7
|
+
data.tar.gz: afee2f7723b316410d1144cf71c42cbace68ff304842cc1c29cd0a358c297ae47f9ae1166e3cd1daef8e677dbdd38b11fb64e771d2d1975afc399cafb8329129
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
acidic_job (1.0.0.
|
4
|
+
acidic_job (1.0.0.pre17)
|
5
5
|
activerecord
|
6
6
|
activesupport
|
7
7
|
database_cleaner
|
@@ -205,7 +205,7 @@ GEM
|
|
205
205
|
rubocop-rake (0.6.0)
|
206
206
|
rubocop (~> 1.0)
|
207
207
|
ruby-progressbar (1.11.0)
|
208
|
-
sidekiq (6.4.
|
208
|
+
sidekiq (6.4.2)
|
209
209
|
connection_pool (>= 2.2.2)
|
210
210
|
rack (~> 2.0)
|
211
211
|
redis (>= 4.2.0)
|
@@ -25,12 +25,16 @@ module AcidicJob
|
|
25
25
|
# and `AcidicJob::DeliverAcidicly#deliver_acidicly`
|
26
26
|
def serialize_with_arguments(args = [], _kwargs = nil)
|
27
27
|
# THIS IS A HACK THAT ESSENTIALLY COPIES THE CODE FROM THE SIDEKIQ CODEBASE TO MIMIC THE BEHAVIOR
|
28
|
+
# updated to handle Sidekiq v6.4.2 at latest
|
28
29
|
args = Array[args]
|
29
30
|
normalized_args = ::Sidekiq.load_json(::Sidekiq.dump_json(args))
|
30
31
|
item = { "class" => self, "args" => normalized_args }
|
31
32
|
dummy_sidekiq_client = ::Sidekiq::Client.new
|
32
33
|
normed = dummy_sidekiq_client.send :normalize_item, item
|
33
|
-
dummy_sidekiq_client.
|
34
|
+
redis_pool = dummy_sidekiq_client.instance_variable_get(:@redis_pool)
|
35
|
+
dummy_sidekiq_client.middleware.invoke(normed["class"], normed, normed["queue"], redis_pool) do
|
36
|
+
normed
|
37
|
+
end
|
34
38
|
end
|
35
39
|
end
|
36
40
|
|
data/lib/acidic_job/step.rb
CHANGED
@@ -52,6 +52,12 @@ module AcidicJob
|
|
52
52
|
# {"does" => :enqueue_step, "then" => :next_step, "awaits" => [WorkerWithEnqueueStep::FirstWorker]}
|
53
53
|
current_step = step["does"]
|
54
54
|
next_step = step["then"]
|
55
|
+
# to support iteration within steps
|
56
|
+
iterable_key = step["for_each"]
|
57
|
+
iterated_key = "processed_#{iterable_key}"
|
58
|
+
iterables = @run.attr_accessors.fetch(iterable_key, [])
|
59
|
+
iterateds = @run.attr_accessors.fetch(iterated_key, [])
|
60
|
+
next_item = iterables.reject { |item| iterateds.include? item }.first
|
55
61
|
|
56
62
|
# jobs can have no-op steps, especially so that they can use only the async/await mechanism for that step
|
57
63
|
callable = if @job.respond_to?(current_step, _include_private = true)
|
@@ -62,7 +68,11 @@ module AcidicJob
|
|
62
68
|
|
63
69
|
# return a callable Proc with a consistent interface for the execution phase
|
64
70
|
proc do |run|
|
65
|
-
result = if
|
71
|
+
result = if iterable_key.present? && next_item.present?
|
72
|
+
callable.call(next_item)
|
73
|
+
elsif iterable_key.present? && next_item.nil?
|
74
|
+
true
|
75
|
+
elsif callable.arity.zero?
|
66
76
|
callable.call
|
67
77
|
elsif callable.arity == 1
|
68
78
|
callable.call(run)
|
@@ -72,6 +82,11 @@ module AcidicJob
|
|
72
82
|
|
73
83
|
if result.is_a?(FinishedPoint)
|
74
84
|
result
|
85
|
+
elsif next_item.present?
|
86
|
+
iterateds << next_item
|
87
|
+
@run.attr_accessors[iterated_key] = iterateds
|
88
|
+
@run.save!(validate: false)
|
89
|
+
RecoveryPoint.new(current_step)
|
75
90
|
elsif next_step.to_s == Run::FINISHED_RECOVERY_POINT
|
76
91
|
FinishedPoint.new
|
77
92
|
else
|
data/lib/acidic_job/version.rb
CHANGED
data/lib/acidic_job.rb
CHANGED
@@ -131,7 +131,7 @@ module AcidicJob
|
|
131
131
|
return run.succeeded? if run.finished?
|
132
132
|
|
133
133
|
# otherwise, we will enter a loop to process each step of the workflow
|
134
|
-
|
134
|
+
loop do
|
135
135
|
recovery_point = run.recovery_point.to_s
|
136
136
|
current_step = run.workflow[recovery_point]
|
137
137
|
|
@@ -170,12 +170,13 @@ module AcidicJob
|
|
170
170
|
run.succeeded?
|
171
171
|
end
|
172
172
|
|
173
|
-
def step(method_name, awaits: [])
|
173
|
+
def step(method_name, awaits: [], for_each: nil)
|
174
174
|
@__acidic_job_steps ||= []
|
175
175
|
|
176
176
|
@__acidic_job_steps << {
|
177
177
|
"does" => method_name.to_s,
|
178
|
-
"awaits" => awaits
|
178
|
+
"awaits" => awaits,
|
179
|
+
"for_each" => for_each
|
179
180
|
}
|
180
181
|
|
181
182
|
@__acidic_job_steps
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acidic_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.pre17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fractaledmind
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|