2017-10-13 16:50:36 +00:00
|
|
|
# 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-02-19 18:09:10 +00:00
|
|
|
class AdvanceStageWorker # rubocop:disable Scalability/IdempotentWorker
|
2017-11-28 16:08:30 +00:00
|
|
|
include ApplicationWorker
|
2021-04-30 18:10:09 +00:00
|
|
|
|
2021-07-21 12:09:35 +00:00
|
|
|
data_consistency :always
|
|
|
|
|
2021-04-30 18:10:09 +00:00
|
|
|
sidekiq_options retry: 3
|
2020-03-12 15:09:39 +00:00
|
|
|
include ::Gitlab::Import::AdvanceStage
|
2017-10-13 16:50:36 +00:00
|
|
|
|
2017-11-28 16:16:50 +00:00
|
|
|
sidekiq_options dead: false
|
2019-10-18 11:11:44 +00:00
|
|
|
feature_category :importers
|
2020-06-12 12:08:56 +00:00
|
|
|
loggable_arguments 1, 2
|
2017-10-13 16:50:36 +00:00
|
|
|
|
|
|
|
# The known importer stages and their corresponding Sidekiq workers.
|
|
|
|
STAGES = {
|
2020-11-28 06:09:28 +00:00
|
|
|
pull_requests_merged_by: Stage::ImportPullRequestsMergedByWorker,
|
2020-11-29 18:09:41 +00:00
|
|
|
pull_request_reviews: Stage::ImportPullRequestsReviewsWorker,
|
2017-10-13 16:50:36 +00:00
|
|
|
issues_and_diff_notes: Stage::ImportIssuesAndDiffNotesWorker,
|
2022-06-30 21:09:49 +00:00
|
|
|
issue_events: Stage::ImportIssueEventsWorker,
|
2017-10-13 16:50:36 +00:00
|
|
|
notes: Stage::ImportNotesWorker,
|
2018-06-06 16:42:18 +00:00
|
|
|
lfs_objects: Stage::ImportLfsObjectsWorker,
|
2017-10-13 16:50:36 +00:00
|
|
|
finish: Stage::FinishImportWorker
|
|
|
|
}.freeze
|
|
|
|
|
2020-04-02 12:08:18 +00:00
|
|
|
def find_import_state(project_id)
|
|
|
|
ProjectImportState.jid_by(project_id: project_id, status: :started)
|
|
|
|
end
|
|
|
|
|
2020-03-18 12:09:13 +00:00
|
|
|
private
|
|
|
|
|
2020-03-12 15:09:39 +00:00
|
|
|
def next_stage_worker(next_stage)
|
|
|
|
STAGES.fetch(next_stage.to_sym)
|
2017-10-13 16:50:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|