lib/acidic_job/awaiting.rb in acidic_job-1.0.0.pre13 vs lib/acidic_job/awaiting.rb in acidic_job-1.0.0.pre14

- old
+ new

@@ -4,50 +4,35 @@ module AcidicJob module Awaiting extend ActiveSupport::Concern - class_methods do - # TODO: Allow the `perform` method to be used to kick off Sidekiq Batch powered workflows - def initiate(*args) - raise SidekiqBatchRequired unless defined?(Sidekiq::Batch) - - top_level_workflow = Sidekiq::Batch.new - top_level_workflow.on(:success, self, *args) - top_level_workflow.jobs do - perform_async - end - end - end - def enqueue_step_parallel_jobs(jobs, run, step_result) # `batch` is available from Sidekiq::Pro raise SidekiqBatchRequired unless defined?(Sidekiq::Batch) - batch.jobs do - step_batch = Sidekiq::Batch.new - # step_batch.description = "AcidicJob::Workflow Step: #{step}" - step_batch.on( - :success, - "#{self.class.name}#step_done", - # NOTE: options are marshalled through JSON so use only basic types. - { "run_id" => run.id, - "step_result_yaml" => step_result.to_yaml.strip } - ) - # NOTE: The jobs method is atomic. - # All jobs created in the block are actually pushed atomically at the end of the block. - # If an error is raised, none of the jobs will go to Redis. - step_batch.jobs do - jobs.each do |worker_name| - # TODO: handle Symbols as well - worker = worker_name.is_a?(String) ? worker_name.constantize : worker_name - if worker.instance_method(:perform).arity.zero? - worker.perform_async - elsif worker.instance_method(:perform).arity == 1 - worker.perform_async(run.id) - else - raise TooManyParametersForParallelJob - end + step_batch = Sidekiq::Batch.new + # step_batch.description = "AcidicJob::Workflow Step: #{step}" + step_batch.on( + :success, + "#{self.class.name}#step_done", + # NOTE: options are marshalled through JSON so use only basic types. + { "run_id" => run.id, + "step_result_yaml" => step_result.to_yaml.strip } + ) + # NOTE: The jobs method is atomic. + # All jobs created in the block are actually pushed atomically at the end of the block. + # If an error is raised, none of the jobs will go to Redis. + step_batch.jobs do + jobs.each do |worker_name| + # TODO: handle Symbols as well + worker = worker_name.is_a?(String) ? worker_name.constantize : worker_name + if worker.instance_method(:perform).arity.zero? + worker.perform_async + elsif worker.instance_method(:perform).arity == 1 + worker.perform_async(run.id) + else + raise TooManyParametersForParallelJob end end end end