gitlab-org--gitlab-foss/lib/gitlab/polling_interval.rb
2018-10-22 07:00:50 +00:00

22 lines
512 B
Ruby

# frozen_string_literal: true
module Gitlab
class PollingInterval
HEADER_NAME = 'Poll-Interval'.freeze
def self.set_header(response, interval:)
if polling_enabled?
multiplier = Gitlab::CurrentSettings.polling_interval_multiplier
value = (interval * multiplier).to_i
else
value = -1
end
response.headers[HEADER_NAME] = value.to_s
end
def self.polling_enabled?
!Gitlab::CurrentSettings.polling_interval_multiplier.zero?
end
end
end