2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
module Gitlab
|
|
|
|
class PollingInterval
|
|
|
|
HEADER_NAME = 'Poll-Interval'.freeze
|
|
|
|
|
|
|
|
def self.set_header(response, interval:)
|
|
|
|
if polling_enabled?
|
2018-03-17 18:26:18 +05:30
|
|
|
multiplier = Gitlab::CurrentSettings.polling_interval_multiplier
|
2017-08-17 22:00:37 +05:30
|
|
|
value = (interval * multiplier).to_i
|
|
|
|
else
|
|
|
|
value = -1
|
|
|
|
end
|
|
|
|
|
|
|
|
response.headers[HEADER_NAME] = value.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.polling_enabled?
|
2018-03-17 18:26:18 +05:30
|
|
|
!Gitlab::CurrentSettings.polling_interval_multiplier.zero?
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|