Class: BulkImports::PipelineWorker

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

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary collapse

NDJSON_PIPELINE_PERFORM_DELAY =
10.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(pipeline_tracker_id, stage, entity_id) ⇒ 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
# File 'app/workers/bulk_imports/pipeline_worker.rb', line 14

def perform(pipeline_tracker_id, stage, entity_id)
  pipeline_tracker = ::BulkImports::Tracker
    .with_status(:enqueued)
    .find_by_id(pipeline_tracker_id)

  if pipeline_tracker.present?
    logger.info(
      structured_payload(
        entity_id: pipeline_tracker.entity.id,
        pipeline_name: pipeline_tracker.pipeline_name
      )
    )

    run(pipeline_tracker)
  else
    logger.error(
      structured_payload(
        entity_id: entity_id,
        pipeline_tracker_id: pipeline_tracker_id,
        message: 'Unstarted pipeline not found'
      )
    )
  end

ensure
  ::BulkImports::EntityWorker.perform_async(entity_id, stage)
end