BigW Consortium Gitlab

sidekiq_throttler.rb 613 Bytes
Newer Older
1 2 3 4 5
module Gitlab
  class SidekiqThrottler
    class << self
      def execute!
        if Gitlab::CurrentSettings.sidekiq_throttling_enabled?
6 7
          Gitlab::CurrentSettings.current_application_settings.sidekiq_throttling_queues.each do |queue|
            Sidekiq::Queue[queue].limit = queue_limit
8 9 10 11 12 13
          end
        end
      end

      private

14 15 16 17 18 19
      def queue_limit
        @queue_limit ||=
          begin
            factor = Gitlab::CurrentSettings.current_application_settings.sidekiq_throttling_factor
            (factor * Sidekiq.options[:concurrency]).ceil
          end
20 21 22 23
      end
    end
  end
end