Class: Gitlab::PollingInterval

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/polling_interval.rb

Constant Summary collapse

HEADER_NAME =
'Poll-Interval'

Class Method Summary collapse

Class Method Details

.polling_enabled?Boolean

Returns:

  • (Boolean)

22
23
24
# File 'lib/gitlab/polling_interval.rb', line 22

def self.polling_enabled?
  Gitlab::CurrentSettings.polling_interval_multiplier != 0
end

.polling_interval_value(interval) ⇒ Object


15
16
17
18
19
20
# File 'lib/gitlab/polling_interval.rb', line 15

def self.polling_interval_value(interval)
  return -1 unless polling_enabled?

  multiplier = Gitlab::CurrentSettings.polling_interval_multiplier
  (interval * multiplier).to_i
end

.set_api_header(context, interval:) ⇒ Object


11
12
13
# File 'lib/gitlab/polling_interval.rb', line 11

def self.set_api_header(context, interval:)
  context.header HEADER_NAME, polling_interval_value(interval).to_s
end

.set_header(response, interval:) ⇒ Object


7
8
9
# File 'lib/gitlab/polling_interval.rb', line 7

def self.set_header(response, interval:)
  response.headers[HEADER_NAME] = polling_interval_value(interval).to_s
end