Welcome to mirror list, hosted at ThFree Co, Russian Federation.

delete_objects_worker.rb « ci « workers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cbcad3e88385f6746461f7e7605cb6a2b7e0ebd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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
# frozen_string_literal: true

module Ci
  class DeleteObjectsWorker
    include ApplicationWorker

    data_consistency :always

    sidekiq_options retry: 3
    include LimitedCapacity::Worker

    feature_category :continuous_integration
    idempotent!

    def perform_work(*args)
      service.execute
    end

    def remaining_work_count(*args)
      @remaining_work_count ||= service
        .remaining_batches_count(max_batch_count: max_running_jobs)
    end

    def max_running_jobs
      if ::Feature.enabled?(:ci_delete_objects_medium_concurrency)
        20
      elsif ::Feature.enabled?(:ci_delete_objects_high_concurrency)
        50
      else
        2
      end
    end

    private

    def service
      @service ||= DeleteObjectsService.new
    end
  end
end