Class: Hekenga::ParallelTask
- Inherits:
-
Object
- Object
- Hekenga::ParallelTask
- Defined in:
- lib/hekenga/parallel_task.rb
Instance Attribute Summary collapse
-
#migration ⇒ Object
readonly
Returns the value of attribute migration.
-
#task ⇒ Object
readonly
Returns the value of attribute task.
-
#task_idx ⇒ Object
readonly
Returns the value of attribute task_idx.
-
#test_mode ⇒ Object
readonly
Returns the value of attribute test_mode.
Instance Method Summary collapse
- #check_for_completion! ⇒ Object
- #complete? ⇒ Boolean
-
#initialize(migration:, task:, task_idx:, test_mode:) ⇒ ParallelTask
constructor
A new instance of ParallelTask.
- #resume! ⇒ Object
- #start! ⇒ Object
Constructor Details
#initialize(migration:, task:, task_idx:, test_mode:) ⇒ ParallelTask
Returns a new instance of ParallelTask.
9 10 11 12 13 14 |
# File 'lib/hekenga/parallel_task.rb', line 9 def initialize(migration:, task:, task_idx:, test_mode:) @migration = migration @task = task @task_idx = task_idx @test_mode = test_mode end |
Instance Attribute Details
#migration ⇒ Object (readonly)
Returns the value of attribute migration.
7 8 9 |
# File 'lib/hekenga/parallel_task.rb', line 7 def migration @migration end |
#task ⇒ Object (readonly)
Returns the value of attribute task.
7 8 9 |
# File 'lib/hekenga/parallel_task.rb', line 7 def task @task end |
#task_idx ⇒ Object (readonly)
Returns the value of attribute task_idx.
7 8 9 |
# File 'lib/hekenga/parallel_task.rb', line 7 def task_idx @task_idx end |
#test_mode ⇒ Object (readonly)
Returns the value of attribute test_mode.
7 8 9 |
# File 'lib/hekenga/parallel_task.rb', line 7 def test_mode @test_mode end |
Instance Method Details
#check_for_completion! ⇒ Object
36 37 38 39 40 |
# File 'lib/hekenga/parallel_task.rb', line 36 def check_for_completion! if complete? migration.log(task_idx).set_without_session(done: true, finished: Time.now) end end |
#complete? ⇒ Boolean
32 33 34 |
# File 'lib/hekenga/parallel_task.rb', line 32 def complete? task_records.incomplete.none? end |
#resume! ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/hekenga/parallel_task.rb', line 23 def resume! regenerate_executor_key task_records.set(executor_key: @executor_key) queue_jobs!(task_records.incomplete) generate_new_records! recover_failed_records! check_for_completion! end |
#start! ⇒ Object
16 17 18 19 20 21 |
# File 'lib/hekenga/parallel_task.rb', line 16 def start! clear_task_records! regenerate_executor_key generate_for_scope(task.scope) check_for_completion! end |