Module: ParallelWorkforce

Defined in:
lib/parallel_workforce.rb,
lib/parallel_workforce/version.rb,
lib/parallel_workforce/executor.rb,
lib/parallel_workforce/job/sidekiq.rb,
lib/parallel_workforce/configuration.rb,
lib/parallel_workforce/job/active_job.rb,
lib/parallel_workforce/job/sidekiq_rails.rb,
lib/parallel_workforce/job/util/performer.rb,
lib/parallel_workforce/serializer/marshal.rb,
lib/parallel_workforce/job/util/job_helper.rb,
lib/parallel_workforce/job/active_job_rails.rb,
lib/parallel_workforce/serializer/json_marshal.rb,
lib/parallel_workforce/redis_connector/redis_pool.rb,
lib/parallel_workforce/revision_builder/files_hash.rb,
lib/parallel_workforce/redis_connector/sidekiq_redis_pool.rb

Defined Under Namespace

Modules: Job, RedisConnector, RevisionBuilder, Serializer Classes: Configuration, Executor

Constant Summary collapse

Error =
Class.new(StandardError)
ActorPerformError =
Class.new(Error)
ActorNotFoundError =
Class.new(Error)
TimeoutError =
Class.new(Error) do
  attr_reader :result_values

  def initialize(message, result_values=nil)
    @result_values = result_values

    super(message)
  end
end
SerializerError =
Class.new(Error)
VERSION =
"4.0.0".freeze

Class Method Summary collapse

Class Method Details

.configurationObject

rubocop:enable Metrics/ParameterLists



36
37
38
# File 'lib/parallel_workforce.rb', line 36

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



40
41
42
# File 'lib/parallel_workforce.rb', line 40

def configure(&block)
  yield(configuration)
end

.log(level, *messages) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/parallel_workforce.rb', line 44

def log(level, *messages)
  return if configuration.logger.nil?

  messages.each do |message|
    configuration.logger.send(level, message)
  end

  nil
end

.perform_all(actor_classes:, actor_args_array:, serial_execution_indexes: nil, execute_serially: nil, job_class: nil, &execution_block) ⇒ Object

actor_classes: a single class or array of classes that have a perform method and can be initialized with no args. If an array is passed, the array size must batch the action_args_array size. Return results array with element from each action in the order of the job_args_array rubocop:disable Metrics/ParameterLists



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/parallel_workforce.rb', line 23

def perform_all(actor_classes:, actor_args_array:,
    serial_execution_indexes: nil, execute_serially: nil, job_class: nil, &execution_block)
  ParallelWorkforce::Executor.new(
    actor_classes: actor_classes,
    actor_args_array: actor_args_array,
    execute_serially: execute_serially,
    serial_execution_indexes: serial_execution_indexes,
    job_class: job_class,
    execution_block: execution_block,
  ).perform_all
end