Class: Rox::Core::ConfigurationFetcher
Instance Method Summary
collapse
#initialize, #write_fetch_error_to_log_and_invoke_fetch_handler, #write_fetch_exception_to_log_and_invoke_fetch_handler
Instance Method Details
#fetch ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/rox/core/network/configuration_fetcher.rb', line 8
def fetch
source = ConfigurationSource::CDN
begin
fetch_result = fetch_from_cdn
if fetch_result.success?
return ConfigurationFetchResult.new(fetch_result.text, source)
else
write_fetch_error_to_log_and_invoke_fetch_handler(source, fetch_result, false, ConfigurationSource::API)
source = ConfigurationSource::API
fetch_result = fetch_from_api
return ConfigurationFetchResult.new(fetch_result.text, source) if fetch_result.success?
end
write_fetch_error_to_log_and_invoke_fetch_handler(source, fetch_result)
rescue StandardError => e
write_fetch_exception_to_log_and_invoke_fetch_handler(source, e)
end
nil
end
|
#fetch_from_api ⇒ Object
33
34
35
36
|
# File 'lib/rox/core/network/configuration_fetcher.rb', line 33
def fetch_from_api
api_request = @request_configuration_builder.build_for_api
@request.send_post(api_request.url, api_request.query_params)
end
|
#fetch_from_cdn ⇒ Object
29
30
31
|
# File 'lib/rox/core/network/configuration_fetcher.rb', line 29
def fetch_from_cdn
@request.send_get(@request_configuration_builder.build_for_cdn)
end
|