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

23 lines
505 B
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
module Gitlab
class PollingInterval
2019-12-04 20:38:33 +05:30
HEADER_NAME = 'Poll-Interval'
2017-08-17 22:00:37 +05:30
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