BigW Consortium Gitlab

polling_interval.rb 527 Bytes
Newer Older
1 2
module Gitlab
  class PollingInterval
3
    extend Gitlab::CurrentSettings
4 5 6 7 8 9 10 11 12 13 14

    HEADER_NAME = 'Poll-Interval'.freeze

    def self.set_header(response, interval:)
      if polling_enabled?
        multiplier = current_application_settings.polling_interval_multiplier
        value = (interval * multiplier).to_i
      else
        value = -1
      end

15
      response.headers[HEADER_NAME] = value.to_s
16 17 18 19 20 21 22
    end

    def self.polling_enabled?
      !current_application_settings.polling_interval_multiplier.zero?
    end
  end
end