Class: VersionCheck
Constant Summary
collapse
- CACHE_VERSION =
Increment when format of cache value is changed
1
ReactiveCaching::ExceededReactiveCacheLimit, ReactiveCaching::InvalidateReactiveCache, ReactiveCaching::WORK_TYPE
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.data ⇒ Object
44
45
46
|
# File 'lib/version_check.rb', line 44
def self.data
{ version: Gitlab::VERSION }
end
|
.from_cache ⇒ Object
62
63
64
|
# File 'lib/version_check.rb', line 62
def self.from_cache(*)
new
end
|
48
49
50
|
# File 'lib/version_check.rb', line 48
def self.
{ "REFERER": Gitlab.config.gitlab.url }
end
|
.host ⇒ Object
58
59
60
|
# File 'lib/version_check.rb', line 58
def self.host
'https://version.gitlab.com'
end
|
.url ⇒ Object
52
53
54
55
56
|
# File 'lib/version_check.rb', line 52
def self.url
encoded_data = Base64.urlsafe_encode64(data.to_json)
"#{host}/check.json?gitlab_info=#{encoded_data}"
end
|
Instance Method Details
#calculate_reactive_cache ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/version_check.rb', line 70
def calculate_reactive_cache(*)
response = Gitlab::HTTP.try_get(self.class.url, headers: self.class.)
case response&.code
when 200
Gitlab::Json.parse(response.body)
else
{ error: 'version check failed', status: response&.code }
end
rescue JSON::ParserError
{ error: 'parsing version check response failed', status: response&.code }
end
|
#response ⇒ Object
83
84
85
86
87
88
89
|
# File 'lib/version_check.rb', line 83
def response
with_reactive_cache do |data|
raise InvalidateReactiveCache if !data.is_a?(Hash) || data[:error]
data
end
end
|