Class: BulkImports::EntityWorker

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

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary

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(entity_id, current_stage = nil) ⇒ Object


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/workers/bulk_imports/entity_worker.rb', line 14

def perform(entity_id, current_stage = nil)
  if stage_running?(entity_id, current_stage)
    logger.info(
      structured_payload(
        entity_id: entity_id,
        current_stage: current_stage,
        message: 'Stage running'
      )
    )

    return
  end

  logger.info(
    structured_payload(
      entity_id: entity_id,
      current_stage: current_stage,
      message: 'Stage starting'
    )
  )

  next_pipeline_trackers_for(entity_id).each do |pipeline_tracker|
    BulkImports::PipelineWorker.perform_async(
      pipeline_tracker.id,
      pipeline_tracker.stage,
      entity_id
    )
  end
rescue StandardError => e
  logger.error(
    structured_payload(
      entity_id: entity_id,
      current_stage: current_stage,
      message: e.message
    )
  )

  Gitlab::ErrorTracking.track_exception(e, entity_id: entity_id)
end