debian-mirror-gitlab/lib/gitlab/sidekiq_throttler.rb

26 lines
654 B
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
module Gitlab
class SidekiqThrottler
class << self
def execute!
if Gitlab::CurrentSettings.sidekiq_throttling_enabled?
2017-09-10 17:25:29 +05:30
require 'sidekiq-limit_fetch'
2017-08-17 22:00:37 +05:30
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