2017-04-03 09:17:04 -04:00
|
|
|
module Gitlab
|
|
|
|
class PollingInterval
|
|
|
|
HEADER_NAME = 'Poll-Interval'.freeze
|
|
|
|
|
|
|
|
def self.set_header(response, interval:)
|
|
|
|
if polling_enabled?
|
2018-02-02 13:39:55 -05:00
|
|
|
multiplier = Gitlab::CurrentSettings.polling_interval_multiplier
|
2017-04-03 09:17:04 -04:00
|
|
|
value = (interval * multiplier).to_i
|
|
|
|
else
|
|
|
|
value = -1
|
|
|
|
end
|
|
|
|
|
2017-04-05 09:35:05 -04:00
|
|
|
response.headers[HEADER_NAME] = value.to_s
|
2017-04-03 09:17:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.polling_enabled?
|
2018-02-02 13:39:55 -05:00
|
|
|
!Gitlab::CurrentSettings.polling_interval_multiplier.zero?
|
2017-04-03 09:17:04 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|