Class: Fractor::Workflow::ParallelExecutionStrategy

Inherits:
ExecutionStrategy show all
Defined in:
lib/fractor/workflow/execution_strategy.rb

Overview

Strategy for executing jobs in parallel. Jobs are executed concurrently using Supervisor.

Instance Attribute Summary

Attributes inherited from ExecutionStrategy

#debug, #executor

Instance Method Summary collapse

Methods inherited from ExecutionStrategy

#initialize, #should_execute_job?

Constructor Details

This class inherits a constructor from Fractor::Workflow::ExecutionStrategy

Instance Method Details

#execute(job_group) ⇒ Boolean

Execute a group of jobs in parallel.

Parameters:

  • job_group (Array<Job>)

    Jobs to execute

Returns:

  • (Boolean)

    true if execution should continue



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/fractor/workflow/execution_strategy.rb', line 174

def execute(job_group)
  log_debug "Executing #{job_group.size} jobs in parallel: #{job_group.map(&:name).join(', ')}"

  executor.send(:execute_jobs_parallel, job_group)

  # Check if any jobs failed
  failed_jobs = job_group.select do |job|
    executor.instance_variable_get(:@failed_jobs).include?(job.name)
  end
  if failed_jobs.any?
    handle_parallel_errors(failed_jobs)
  end

  true
end