add export worker to process project export async

This commit is contained in:
James Lopez 2016-05-04 10:59:33 +02:00
parent 1990616a21
commit bc8eebf04a
2 changed files with 23 additions and 0 deletions

View File

@ -1034,4 +1034,14 @@ class Project < ActiveRecord::Base
def wiki
@wiki ||= ProjectWiki.new(self, self.owner)
end
def add_export_job(current_user_id:)
job_id = ProjectExportWorker.perform_async(current_user_id, self.id)
if job_id
Rails.logger.info "Export job started for project ID #{self.id} with job ID #{job_id}"
else
Rails.logger.error "Export job failed to start for project ID #{self.id}"
end
end
end

View File

@ -0,0 +1,13 @@
class ProjectExportWorker
include Sidekiq::Worker
# TODO: enabled retry - disabled for QA purposes
sidekiq_options queue: :gitlab_shell, retry: false
def perform(current_user_id, project_id)
current_user = User.find(current_user_id)
project = Project.find(project_id)
::Projects::ImportExport::ExportService.new(project, current_user).execute
# TODO : Handle errors
end
end