debian-mirror-gitlab/app/workers/gitlab/github_import/advance_stage_worker.rb

37 lines
1.1 KiB
Ruby
Raw Normal View History

2018-03-17 18:26:18 +05:30
# frozen_string_literal: true
module Gitlab
module GithubImport
# AdvanceStageWorker is a worker used by the GitHub importer to wait for a
# number of jobs to complete, without blocking a thread. Once all jobs have
# been completed this worker will advance the import process to the next
# stage.
2020-04-08 14:13:33 +05:30
class AdvanceStageWorker # rubocop:disable Scalability/IdempotentWorker
2018-03-17 18:26:18 +05:30
include ApplicationWorker
2020-04-08 14:13:33 +05:30
include ::Gitlab::Import::AdvanceStage
2018-03-17 18:26:18 +05:30
sidekiq_options dead: false
2019-12-21 20:55:43 +05:30
feature_category :importers
2020-06-23 00:09:42 +05:30
loggable_arguments 1, 2
2018-03-17 18:26:18 +05:30
# The known importer stages and their corresponding Sidekiq workers.
STAGES = {
issues_and_diff_notes: Stage::ImportIssuesAndDiffNotesWorker,
notes: Stage::ImportNotesWorker,
2018-11-08 19:23:39 +05:30
lfs_objects: Stage::ImportLfsObjectsWorker,
2018-03-17 18:26:18 +05:30
finish: Stage::FinishImportWorker
}.freeze
2020-04-22 19:07:51 +05:30
def find_import_state(project_id)
ProjectImportState.jid_by(project_id: project_id, status: :started)
end
private
2020-04-08 14:13:33 +05:30
def next_stage_worker(next_stage)
STAGES.fetch(next_stage.to_sym)
2018-03-17 18:26:18 +05:30
end
end
end
end