Class: BulkImports::EntityWorker
- Inherits:
-
Object
- Object
- BulkImports::EntityWorker
- Includes:
- ApplicationWorker, ExclusiveLeaseGuard
- Defined in:
- app/workers/bulk_imports/entity_worker.rb
Constant Summary collapse
- PERFORM_DELAY =
5.seconds
Constants included from ApplicationWorker
ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT
Constants included from Gitlab::Loggable
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 ExclusiveLeaseGuard
#exclusive_lease, #lease_release?, #lease_taken_log_level, #lease_taken_message, #release_lease, #renew_lease!, #try_obtain_lease
Methods included from Gitlab::Loggable
Methods included from Gitlab::SidekiqVersioning::Worker
Methods included from WorkerContext
Instance Method Details
#perform(entity_id) ⇒ Object
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 |
# File 'app/workers/bulk_imports/entity_worker.rb', line 21 def perform(entity_id) @entity = ::BulkImports::Entity.find_by_id(entity_id) unless @entity Sidekiq.logger.warn( class: self.class.name, entity_id: entity_id, message: 'Entity not found' ) return end return unless @entity.started? if running_tracker.present? log_info(message: 'Stage running', entity_stage: running_tracker.stage) else # Use lease guard to prevent duplicated workers from starting multiple stages try_obtain_lease do start_next_stage end end re_enqueue end |
#perform_failure(exception, entity_id) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/workers/bulk_imports/entity_worker.rb', line 47 def perform_failure(exception, entity_id) @entity = ::BulkImports::Entity.find_by_id(entity_id) unless @entity Sidekiq.logger.warn( class: self.class.name, entity_id: entity_id, message: 'Entity not found (failure)' ) return end Gitlab::ErrorTracking.track_exception( exception, { message: "Request to export #{entity.source_type} failed" }.merge(logger.default_attributes) ) entity.fail_op! end |