Class: Preneeds::Configuration

Inherits:
Common::Client::Configuration::SOAP show all
Defined in:
lib/preneeds/configuration.rb

Overview

Configuration for the Service to communicate to set the base path, a default timeout, and a service name for breakers and metrics. Communicates with the EOAS external service.

Constant Summary collapse

TIMEOUT =

Number of seconds before timeout

30

Instance Attribute Summary

Attributes inherited from Common::Client::Configuration::Base

#base_request_headers, #open_timeout, #read_timeout, #request_types, #user_agent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Common::Client::Configuration::SOAP

#allow_missing_certs?, #ssl_cert, #ssl_key

Methods inherited from Common::Client::Configuration::Base

#breakers_error_threshold, #breakers_exception_handler, #breakers_matcher, #breakers_service, #create_new_breakers_service, #request_options, #service_exception

Class Method Details

.urlString

Returns The base path for the external EOAS service.

Returns:

  • (String)

    The base path for the external EOAS service



22
23
24
# File 'lib/preneeds/configuration.rb', line 22

def self.url
  "#{Settings.preneeds.host}/eoas_SOA/PreNeedApplicationPort"
end

Instance Method Details

#base_pathString

Returns The base path for the external EOAS service.

Returns:

  • (String)

    The base path for the external EOAS service



28
29
30
# File 'lib/preneeds/configuration.rb', line 28

def base_path
  self.class.url
end

#connectionFaraday::Connection

Creates the a connection with middleware for mapping errors, parsing XML, and adding breakers functionality.

Returns:

  • (Faraday::Connection)

    a Faraday connection instance.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/preneeds/configuration.rb', line 42

def connection
  path = Preneeds::Configuration.url
  @faraday ||= Faraday.new(
    path, headers: base_request_headers, request: request_options, ssl: { verify: false }
  ) do |conn|
    conn.use :breakers

    conn.options.timeout = TIMEOUT

    conn.request :soap_headers

    conn.response :preneeds_parser
    conn.response :soap_parser
    conn.response :eoas_xml_errors
    conn.response :clean_response

    conn.adapter Faraday.default_adapter
  end
end

#service_nameString

Returns The name of the service, used by breakers to set a metric name for the service.

Returns:

  • (String)

    The name of the service, used by breakers to set a metric name for the service



34
35
36
# File 'lib/preneeds/configuration.rb', line 34

def service_name
  'Preneeds'
end