Welcome to mirror list, hosted at ThFree Co, Russian Federation.

polling_interval.rb « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f0c50584f0725da5fe864ef227abe95d86d1ff38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Gitlab
  class PollingInterval
    include Gitlab::CurrentSettings

    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

      response.headers[HEADER_NAME] = value.to_s
    end

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