acidic_job 1.0.0.pre13 → 1.0.0.pre14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/acidic_job/awaiting.rb +22 -37
- data/lib/acidic_job/staging.rb +1 -0
- data/lib/acidic_job/version.rb +1 -1
- data/lib/acidic_job.rb +1 -4
- 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: fcc6621d513d4284bb09bdb4da7433b81b2c240ce9873dbf1348569e76942960
|
4
|
+
data.tar.gz: 411b5819c7faab9f8bcb19f39bd4dc5c8a03d42f28239f5f19489b2f7d01eb68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 644bc4268dfa5c66804e169314f67452b4046bdbbd4b013589b6463e0c79363407d8fbdecfc2db3197cccdb75c558059492b2a9f22a0eca0198f7033836abd05
|
7
|
+
data.tar.gz: 2807478181d478a7ee10e082e7f76f42409e3c587e436712396371d92d8b53481b0606a19bbcb108fa2cb95c4529f4b9ca86b146cf1aec64c53954c57eda5971
|
data/Gemfile.lock
CHANGED
data/lib/acidic_job/awaiting.rb
CHANGED
@@ -6,47 +6,32 @@ module AcidicJob
|
|
6
6
|
module Awaiting
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
|
-
class_methods do
|
10
|
-
# TODO: Allow the `perform` method to be used to kick off Sidekiq Batch powered workflows
|
11
|
-
def initiate(*args)
|
12
|
-
raise SidekiqBatchRequired unless defined?(Sidekiq::Batch)
|
13
|
-
|
14
|
-
top_level_workflow = Sidekiq::Batch.new
|
15
|
-
top_level_workflow.on(:success, self, *args)
|
16
|
-
top_level_workflow.jobs do
|
17
|
-
perform_async
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
9
|
def enqueue_step_parallel_jobs(jobs, run, step_result)
|
23
10
|
# `batch` is available from Sidekiq::Pro
|
24
11
|
raise SidekiqBatchRequired unless defined?(Sidekiq::Batch)
|
25
12
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
raise TooManyParametersForParallelJob
|
49
|
-
end
|
13
|
+
step_batch = Sidekiq::Batch.new
|
14
|
+
# step_batch.description = "AcidicJob::Workflow Step: #{step}"
|
15
|
+
step_batch.on(
|
16
|
+
:success,
|
17
|
+
"#{self.class.name}#step_done",
|
18
|
+
# NOTE: options are marshalled through JSON so use only basic types.
|
19
|
+
{ "run_id" => run.id,
|
20
|
+
"step_result_yaml" => step_result.to_yaml.strip }
|
21
|
+
)
|
22
|
+
# NOTE: The jobs method is atomic.
|
23
|
+
# All jobs created in the block are actually pushed atomically at the end of the block.
|
24
|
+
# If an error is raised, none of the jobs will go to Redis.
|
25
|
+
step_batch.jobs do
|
26
|
+
jobs.each do |worker_name|
|
27
|
+
# TODO: handle Symbols as well
|
28
|
+
worker = worker_name.is_a?(String) ? worker_name.constantize : worker_name
|
29
|
+
if worker.instance_method(:perform).arity.zero?
|
30
|
+
worker.perform_async
|
31
|
+
elsif worker.instance_method(:perform).arity == 1
|
32
|
+
worker.perform_async(run.id)
|
33
|
+
else
|
34
|
+
raise TooManyParametersForParallelJob
|
50
35
|
end
|
51
36
|
end
|
52
37
|
end
|
data/lib/acidic_job/staging.rb
CHANGED
data/lib/acidic_job/version.rb
CHANGED
data/lib/acidic_job.rb
CHANGED
@@ -82,8 +82,6 @@ module AcidicJob
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def with_acidity(providing: {})
|
85
|
-
# ensure this instance variable is always defined
|
86
|
-
@__acidic_job_steps = []
|
87
85
|
# execute the block to gather the info on what steps are defined for this job workflow
|
88
86
|
yield
|
89
87
|
|
@@ -112,7 +110,6 @@ module AcidicJob
|
|
112
110
|
FinishedPoint.new
|
113
111
|
end
|
114
112
|
|
115
|
-
# TODO: allow idempotency to be defined by args OR job id
|
116
113
|
# rubocop:disable Naming/MemoizedInstanceVariableName
|
117
114
|
def idempotency_key
|
118
115
|
if defined?(@__acidic_job_idempotency_key) && !@__acidic_job_idempotency_key.nil?
|
@@ -138,7 +135,7 @@ module AcidicJob
|
|
138
135
|
|
139
136
|
# if any step calls `safely_finish_acidic_job` or the workflow has simply completed,
|
140
137
|
# be sure to break out of the loop
|
141
|
-
if recovery_point == Run::FINISHED_RECOVERY_POINT.to_s # rubocop:disable Style/GuardClause
|
138
|
+
if recovery_point.to_s == Run::FINISHED_RECOVERY_POINT.to_s # rubocop:disable Style/GuardClause
|
142
139
|
break
|
143
140
|
elsif current_step.nil?
|
144
141
|
raise UnknownRecoveryPoint, "Defined workflow does not reference this step: #{recovery_point}"
|
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.pre14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fractaledmind
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|