Class: Lab::Lims::Migrator::MigrationWorker
- Inherits:
-
PullWorker
- Object
- PullWorker
- Lab::Lims::Migrator::MigrationWorker
- Defined in:
- app/services/lab/lims/migrator.rb
Overview
Extends the PullWorker to provide pause/resume capabilities.
Migrations can be take a long time to complete, in cases where something went wrong you wouldn’t to start all over. This worker thus saves progress and allows for the process to continue from whether it stopped.
Constant Summary collapse
- LOG_FILE_PATH =
Utils::LIMS_LOG_PATH.join('migration-last-id.dat')
Constants inherited from PullWorker
Constants included from Utils
Utils::LIMS_LOG_PATH, Utils::TEST_NAME_MAPPINGS
Instance Attribute Summary collapse
-
#rejections ⇒ Object
readonly
Returns the value of attribute rejections.
Attributes inherited from PullWorker
Instance Method Summary collapse
-
#initialize(api_class) ⇒ MigrationWorker
constructor
A new instance of MigrationWorker.
- #last_seq ⇒ Object
Methods inherited from PullWorker
Methods included from Utils
find_concept_by_name, lab_user, #logger, parse_date, structify, translate_test_name
Constructor Details
#initialize(api_class) ⇒ MigrationWorker
Returns a new instance of MigrationWorker.
116 117 118 119 |
# File 'app/services/lab/lims/migrator.rb', line 116 def initialize(api_class) api = api_class.new(processes: MAX_THREADS, on_merge_processes: method(:save_seq)) super(api) end |
Instance Attribute Details
#rejections ⇒ Object (readonly)
Returns the value of attribute rejections.
114 115 116 |
# File 'app/services/lab/lims/migrator.rb', line 114 def rejections @rejections end |
Instance Method Details
#last_seq ⇒ Object
121 122 123 124 125 126 127 128 |
# File 'app/services/lab/lims/migrator.rb', line 121 def last_seq return 0 unless File.exist?(LOG_FILE_PATH) File.open(LOG_FILE_PATH, File::RDONLY) do |file| last_seq = file.read&.strip return last_seq.blank? ? nil : last_seq&.to_i end end |