Class: Rox::Core::ConfigurationFetcherBase

Inherits:
Object
  • Object
show all
Defined in:
lib/rox/core/network/configuration_fetcher_base.rb

Instance Method Summary collapse

Constructor Details

#initialize(request_configuration_builder, request, configuration_fetched_invoker) ⇒ ConfigurationFetcherBase

Returns a new instance of ConfigurationFetcherBase.



7
8
9
10
11
# File 'lib/rox/core/network/configuration_fetcher_base.rb', line 7

def initialize(request_configuration_builder, request, configuration_fetched_invoker)
  @request_configuration_builder = request_configuration_builder
  @request = request
  @configuration_fetched_invoker = configuration_fetched_invoker
end

Instance Method Details

#write_fetch_error_to_log_and_invoke_fetch_handler(source, response, raise_configuration_handler = true, next_source = nil) ⇒ Object



13
14
15
16
17
# File 'lib/rox/core/network/configuration_fetcher_base.rb', line 13

def write_fetch_error_to_log_and_invoke_fetch_handler(source, response, raise_configuration_handler = true, next_source = nil)
  retry_msg = next_source.nil? ? '' : "Trying from #{next_source}. "
  Logging.logger.debug("Failed to fetch from #{source}. #{retry_msg}http error code: #{response.status_code}")
  @configuration_fetched_invoker.invoke_error(FetcherError::NETWORK_ERROR) if raise_configuration_handler
end

#write_fetch_exception_to_log_and_invoke_fetch_handler(source, ex) ⇒ Object



19
20
21
22
# File 'lib/rox/core/network/configuration_fetcher_base.rb', line 19

def write_fetch_exception_to_log_and_invoke_fetch_handler(source, ex)
  Logging.logger.error("Failed to fetch configuration. Source: #{source}. Ex: #{ex}")
  @configuration_fetched_invoker.invoke_error(FetcherError::NETWORK_ERROR)
end