Class: Ci::Catalog::Resources::ProcessSyncEventsWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, CronjobQueue
Defined in:
app/workers/ci/catalog/resources/process_sync_events_worker.rb

Overview

This worker can be called multiple times simultaneously but only one can process events at a time. This is ensured by try_obtain_lease in Ci::ProcessSyncEventsService.

This worker is enqueued in 3 ways:

  1. By Project model callback after updating one of the columns referenced in ‘Ci::Catalog::Resource#sync_with_project`.

  2. Every minute by cron job. This ensures we process SyncEvents from direct/bulk database updates that do not use the Project AR model.

  3. By Ci::ProcessSyncEventsService if there are any remaining pending SyncEvents after processing.

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from Gitlab::Loggable

Gitlab::Loggable::ANONYMOUS

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_CONCURRENCY_LIMIT_PERCENTAGE_BY_URGENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY_PER_DB, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::LOAD_BALANCED_DATA_CONSISTENCIES, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::Loggable

#build_structured_payload

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#performObject



29
30
31
32
33
34
35
36
37
# File 'app/workers/ci/catalog/resources/process_sync_events_worker.rb', line 29

def perform
  results = ::Ci::ProcessSyncEventsService.new(
    ::Ci::Catalog::Resources::SyncEvent, ::Ci::Catalog::Resource
  ).execute

  results.each do |key, value|
    (key, value)
  end
end