Class: BulkImportWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker
Defined in:
app/workers/bulk_import_worker.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary collapse

PERFORM_DELAY =
5.seconds

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#perform(bulk_import_id) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/workers/bulk_import_worker.rb', line 12

def perform(bulk_import_id)
  @bulk_import = BulkImport.find_by_id(bulk_import_id)

  return unless @bulk_import
  return if @bulk_import.finished? || @bulk_import.failed?
  return @bulk_import.fail_op! if all_entities_failed?
  return @bulk_import.finish! if all_entities_processed? && @bulk_import.started?

  @bulk_import.start! if @bulk_import.created?

  created_entities.find_each do |entity|
    entity.create_pipeline_trackers!

    BulkImports::ExportRequestWorker.perform_async(entity.id)
    BulkImports::EntityWorker.perform_async(entity.id)

    entity.start!
  end

  re_enqueue
rescue StandardError => e
  Gitlab::ErrorTracking.track_exception(e, bulk_import_id: @bulk_import&.id)

  @bulk_import&.fail_op
end