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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff4783bfe9e3ff6a03683ed14a9f21a5227f6114bc5824cdee71a66f252d7fa1
4
- data.tar.gz: d905d8ad1848d77ae9fade6b75527ae113675ba3c39b66149c750f9adb64d83b
3
+ metadata.gz: fcc6621d513d4284bb09bdb4da7433b81b2c240ce9873dbf1348569e76942960
4
+ data.tar.gz: 411b5819c7faab9f8bcb19f39bd4dc5c8a03d42f28239f5f19489b2f7d01eb68
5
5
  SHA512:
6
- metadata.gz: 1af39ccff6bb5d414ab32344887d60f4cf721d9272ec0c98c9686053d3426fd2da98d82b9fe35fd45ebc6b719b8e1df6ce922abbec86653a91bea736f9522696
7
- data.tar.gz: f0f8db378646cd3e948a2406c2237b44c9e6a551dafcbe1a687cbfadc5a15713e3b6a177a18ccf81146b024cb64b44085a14c8250fd8b364f16c911d3a202f5b
6
+ metadata.gz: 644bc4268dfa5c66804e169314f67452b4046bdbbd4b013589b6463e0c79363407d8fbdecfc2db3197cccdb75c558059492b2a9f22a0eca0198f7033836abd05
7
+ data.tar.gz: 2807478181d478a7ee10e082e7f76f42409e3c587e436712396371d92d8b53481b0606a19bbcb108fa2cb95c4529f4b9ca86b146cf1aec64c53954c57eda5971
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- acidic_job (1.0.0.pre13)
4
+ acidic_job (1.0.0.pre14)
5
5
  activerecord (>= 6.1.0)
6
6
  activesupport
7
7
 
@@ -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
- batch.jobs do
27
- step_batch = Sidekiq::Batch.new
28
- # step_batch.description = "AcidicJob::Workflow Step: #{step}"
29
- step_batch.on(
30
- :success,
31
- "#{self.class.name}#step_done",
32
- # NOTE: options are marshalled through JSON so use only basic types.
33
- { "run_id" => run.id,
34
- "step_result_yaml" => step_result.to_yaml.strip }
35
- )
36
- # NOTE: The jobs method is atomic.
37
- # All jobs created in the block are actually pushed atomically at the end of the block.
38
- # If an error is raised, none of the jobs will go to Redis.
39
- step_batch.jobs do
40
- jobs.each do |worker_name|
41
- # TODO: handle Symbols as well
42
- worker = worker_name.is_a?(String) ? worker_name.constantize : worker_name
43
- if worker.instance_method(:perform).arity.zero?
44
- worker.perform_async
45
- elsif worker.instance_method(:perform).arity == 1
46
- worker.perform_async(run.id)
47
- else
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
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/concern"
4
+ require "global_id/locator"
4
5
 
5
6
  module AcidicJob
6
7
  module Staging
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AcidicJob
4
- VERSION = "1.0.0.pre13"
4
+ VERSION = "1.0.0.pre14"
5
5
  end
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.pre13
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-16 00:00:00.000000000 Z
11
+ date: 2022-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord