Class: ChainedJob::StartChains
- Inherits:
-
Object
- Object
- ChainedJob::StartChains
- Defined in:
- lib/chained_job/start_chains.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#array_of_job_arguments ⇒ Object
readonly
Returns the value of attribute array_of_job_arguments.
-
#job_arguments_key ⇒ Object
readonly
Returns the value of attribute job_arguments_key.
-
#job_class ⇒ Object
readonly
Returns the value of attribute job_class.
-
#parallelism ⇒ Object
readonly
Returns the value of attribute parallelism.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args, job_class, job_arguments_key, array_of_job_arguments, parallelism) ⇒ StartChains
constructor
A new instance of StartChains.
-
#run ⇒ Object
rubocop:disable Metrics/AbcSize.
Constructor Details
#initialize(args, job_class, job_arguments_key, array_of_job_arguments, parallelism) ⇒ StartChains
Returns a new instance of StartChains.
15 16 17 18 19 20 21 |
# File 'lib/chained_job/start_chains.rb', line 15 def initialize(args, job_class, job_arguments_key, array_of_job_arguments, parallelism) @args = args @job_class = job_class @job_arguments_key = job_arguments_key @array_of_job_arguments = array_of_job_arguments @parallelism = parallelism end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
13 14 15 |
# File 'lib/chained_job/start_chains.rb', line 13 def args @args end |
#array_of_job_arguments ⇒ Object (readonly)
Returns the value of attribute array_of_job_arguments.
13 14 15 |
# File 'lib/chained_job/start_chains.rb', line 13 def array_of_job_arguments @array_of_job_arguments end |
#job_arguments_key ⇒ Object (readonly)
Returns the value of attribute job_arguments_key.
13 14 15 |
# File 'lib/chained_job/start_chains.rb', line 13 def job_arguments_key @job_arguments_key end |
#job_class ⇒ Object (readonly)
Returns the value of attribute job_class.
13 14 15 |
# File 'lib/chained_job/start_chains.rb', line 13 def job_class @job_class end |
#parallelism ⇒ Object (readonly)
Returns the value of attribute parallelism.
13 14 15 |
# File 'lib/chained_job/start_chains.rb', line 13 def parallelism @parallelism end |
Class Method Details
.run(args, job_class, job_arguments_key, array_of_job_arguments, parallelism) ⇒ Object
9 10 11 |
# File 'lib/chained_job/start_chains.rb', line 9 def self.run(args, job_class, job_arguments_key, array_of_job_arguments, parallelism) new(args, job_class, job_arguments_key, array_of_job_arguments, parallelism).run end |
Instance Method Details
#run ⇒ Object
rubocop:disable Metrics/AbcSize
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/chained_job/start_chains.rb', line 24 def run with_hooks do log_chained_job_cleanup ChainedJob::CleanUpQueue.run(job_arguments_key) next unless array_of_job_arguments.count.positive? ChainedJob::StoreJobArguments.run(job_arguments_key, job_tag, array_of_job_arguments) log_chained_job_start parallelism.times { |worked_id| job_class.perform_later(args, worked_id, job_tag) } end end |