Class: BulkImports::RelationBatchExportWorker
  
  
  
  
  
    - Inherits:
 
    - 
      Object
      
        
          - Object
 
          
            - BulkImports::RelationBatchExportWorker
 
          
        
        show all
      
     
  
  
  
  
  
  
  
      - Includes:
 
      - ApplicationWorker, Gitlab::Utils::StrongMemoize, Sidekiq::InterruptionsExhausted
 
  
  
  
  
  
  
    - Defined in:
 
    - app/workers/bulk_imports/relation_batch_export_worker.rb
 
  
  
 
  
    
      Constant Summary
      collapse
    
    
      
        - PERFORM_DELAY =
          
        
 
        1.minute
 
      
    
  
  
  
  
  ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT
  
  
  
  Gitlab::Loggable::ANONYMOUS
  
  
  
  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
  
    
      Class Method Summary
      collapse
    
    
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  #build_structured_payload
  
  
  
  
  
  
  
  
  
  #job_version
  
  
  
  
  
  
  
  
  
  
  #with_context
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
    Class Method Details
    
      
  
  
    
      
29
30
31
32
33
34
35
36 
     | 
    
      # File 'app/workers/bulk_imports/relation_batch_export_worker.rb', line 29
def self.perform_failure(job, exception)
  batch = BulkImports::ExportBatch.find(job['args'][1])
  portable = batch.export.portable
  Gitlab::ErrorTracking.track_exception(exception, portable_id: portable.id, portable_type: portable.class.name)
  batch.update!(status_event: 'fail_op', error: exception.message.truncate(255))
end 
     | 
  
 
    
   
  
    Instance Method Details
    
      
  
  
    #max_exports_already_running?  ⇒ Boolean 
  
  
  
  
    
      
52
53
54 
     | 
    
      # File 'app/workers/bulk_imports/relation_batch_export_worker.rb', line 52
def max_exports_already_running?
  BulkImports::ExportBatch.started_and_not_timed_out.limit(max_exports).count == max_exports
end 
     | 
  
 
    
      
  
  
    
      
38
39
40
41
42
43
44
45
46
47
48
49
50 
     | 
    
      # File 'app/workers/bulk_imports/relation_batch_export_worker.rb', line 38
def perform(user_id, batch_id)
  @user = User.find(user_id)
  @batch = BulkImports::ExportBatch.find(batch_id)
  return re_enqueue_job(@user, @batch) if !@batch.started? && max_exports_already_running?
  (:relation, @batch.export.relation)
  (:batch_number, @batch.batch_number)
  RelationBatchExportService.new(@user, @batch).execute
  (:objects_count, @batch.objects_count)
end 
     | 
  
 
    
      
  
  
    #re_enqueue_job(user, batch)  ⇒ Object 
  
  
  
  
    
      
60
61
62
63
64
65 
     | 
    
      # File 'app/workers/bulk_imports/relation_batch_export_worker.rb', line 60
def re_enqueue_job(user, batch)
  reset_cache_timeout(batch)
  (:re_enqueue, true)
  self.class.perform_in(PERFORM_DELAY, user.id, batch.id)
end 
     | 
  
 
    
      
  
  
    #reset_cache_timeout(batch)  ⇒ Object