2016-11-08 17:31:37 -05:00
|
|
|
module Gitlab
|
|
|
|
class SidekiqThrottler
|
|
|
|
class << self
|
|
|
|
def execute!
|
|
|
|
if Gitlab::CurrentSettings.sidekiq_throttling_enabled?
|
2017-08-21 07:50:09 -04:00
|
|
|
require 'sidekiq-limit_fetch'
|
|
|
|
|
2016-11-10 12:36:52 -05:00
|
|
|
Gitlab::CurrentSettings.current_application_settings.sidekiq_throttling_queues.each do |queue|
|
|
|
|
Sidekiq::Queue[queue].limit = queue_limit
|
2016-11-08 17:31:37 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-11-10 12:36:52 -05:00
|
|
|
def queue_limit
|
|
|
|
@queue_limit ||=
|
|
|
|
begin
|
|
|
|
factor = Gitlab::CurrentSettings.current_application_settings.sidekiq_throttling_factor
|
|
|
|
(factor * Sidekiq.options[:concurrency]).ceil
|
|
|
|
end
|
2016-11-08 17:31:37 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|