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

sidekiq_throttler.rb « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d4d39a888e7fe341fcc9eaf4fde0ed1b1093e7c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Gitlab
  class SidekiqThrottler
    class << self
      def execute!
        if Gitlab::CurrentSettings.sidekiq_throttling_enabled?
          Gitlab::CurrentSettings.current_application_settings.sidekiq_throttling_queues.each do |queue|
            Sidekiq::Queue[queue].limit = queue_limit
          end
        end
      end

      private

      def queue_limit
        @queue_limit ||=
          begin
            factor = Gitlab::CurrentSettings.current_application_settings.sidekiq_throttling_factor
            (factor * Sidekiq.options[:concurrency]).ceil
          end
      end
    end
  end
end