diff options
Diffstat (limited to 'lib/gitlab/polling_interval.rb')
-rw-r--r-- | lib/gitlab/polling_interval.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/gitlab/polling_interval.rb b/lib/gitlab/polling_interval.rb index fd66787b029..e286c3d467e 100644 --- a/lib/gitlab/polling_interval.rb +++ b/lib/gitlab/polling_interval.rb @@ -5,14 +5,18 @@ module Gitlab HEADER_NAME = 'Poll-Interval' 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] = polling_interval_value(interval).to_s + end + + def self.set_api_header(context, interval:) + context.header HEADER_NAME, polling_interval_value(interval).to_s + end + + def self.polling_interval_value(interval) + return -1 unless polling_enabled? - response.headers[HEADER_NAME] = value.to_s + multiplier = Gitlab::CurrentSettings.polling_interval_multiplier + (interval * multiplier).to_i end def self.polling_enabled? |