Class: BulkImportWorker
- Inherits:
-
Object
- Object
- BulkImportWorker
- Includes:
- ApplicationWorker
- Defined in:
- app/workers/bulk_import_worker.rb
Overview
rubocop:disable Scalability/IdempotentWorker
Constant Summary collapse
- PERFORM_DELAY =
5.seconds
- DEFAULT_BATCH_SIZE =
5
Constants included from ApplicationWorker
ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT
Constants included from Gitlab::Loggable
Constants included from WorkerAttributes
WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES
Instance Method Summary collapse
Methods included from Gitlab::Loggable
Methods included from Gitlab::SidekiqVersioning::Worker
Methods included from WorkerContext
Instance Method Details
#perform(bulk_import_id) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/workers/bulk_import_worker.rb', line 13 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? return re_enqueue if max_batch_size_exceeded? # Do not start more jobs if max allowed are already running @bulk_import.start! if @bulk_import.created? created_entities.first(next_batch_size).each do |entity| create_tracker(entity) entity.start! BulkImports::ExportRequestWorker.perform_async(entity.id) end re_enqueue rescue StandardError => e Gitlab::ErrorTracking.track_exception(e, bulk_import_id: @bulk_import&.id) @bulk_import&.fail_op end |