Class: Rx::Configuration
- Inherits:
-
Common::Client::Configuration::REST
- Object
- Common::Client::Configuration::Base
- Common::Client::Configuration::REST
- Rx::Configuration
- Defined in:
- lib/rx/configuration.rb
Overview
HTTP client configuration for Client, sets the token, base path and a service name for breakers and metrics
Instance Attribute Summary
Attributes inherited from Common::Client::Configuration::Base
#base_request_headers, #open_timeout, #read_timeout, #request_types, #user_agent
Instance Method Summary collapse
-
#app_token ⇒ String
Client token set in ‘settings.yml` via credstash.
- #app_token_va_gov ⇒ Object
-
#base_path ⇒ String
Base path for dependent URLs.
- #breakers_error_threshold ⇒ Object
-
#caching_enabled? ⇒ Boolean
If the MHV Rx collections should be cached.
-
#connection ⇒ Faraday::Connection
Creates a connection with middleware for mapping errors, parsing XML, and adding breakers functionality.
- #parallel_connection ⇒ Object
-
#service_name ⇒ String
Service name to use in breakers and metrics.
Methods inherited from Common::Client::Configuration::Base
#breakers_exception_handler, #breakers_matcher, #breakers_service, #create_new_breakers_service, #current_module, #request_options, #service_exception
Instance Method Details
#app_token ⇒ String
Returns Client token set in ‘settings.yml` via credstash.
23 24 25 |
# File 'lib/rx/configuration.rb', line 23 def app_token Settings.mhv.rx.app_token end |
#app_token_va_gov ⇒ Object
27 28 29 |
# File 'lib/rx/configuration.rb', line 27 def app_token_va_gov Settings.mhv.rx.app_token_va_gov end |
#base_path ⇒ String
Returns Base path for dependent URLs.
34 35 36 |
# File 'lib/rx/configuration.rb', line 34 def base_path "#{Settings.mhv.rx.host}/mhv-api/patient/v1/" end |
#breakers_error_threshold ⇒ Object
101 102 103 |
# File 'lib/rx/configuration.rb', line 101 def breakers_error_threshold 80 # breakers will be tripped if error rate reaches 80% over a two minute period. end |
#caching_enabled? ⇒ Boolean
Returns if the MHV Rx collections should be cached.
41 42 43 |
# File 'lib/rx/configuration.rb', line 41 def caching_enabled? Settings.mhv.rx.collection_caching_enabled || false end |
#connection ⇒ Faraday::Connection
Creates a connection with middleware for mapping errors, parsing XML, and adding breakers functionality
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rx/configuration.rb', line 60 def connection Faraday.new(base_path, headers: base_request_headers, request: ) do |conn| conn.use :breakers conn.request :json # Uncomment this if you want curl command equivalent or response output to log # conn.request(:curl, ::Logger.new($stdout), :warn) unless Rails.env.production? # conn.response(:logger, ::Logger.new($stdout), bodies: true) unless Rails.env.production? conn.response :betamocks if Settings.mhv.rx.mock conn.response :rx_failed_station conn.response :rx_parser conn.response :snakecase conn.response :rx_raise_error, error_prefix: service_name conn.response :mhv_errors conn.response :mhv_xml_html_errors conn.response :json_parser conn.adapter Faraday.default_adapter end end |
#parallel_connection ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/rx/configuration.rb', line 82 def parallel_connection Faraday.new(base_path, headers: base_request_headers, request: ) do |conn| conn.use :breakers conn.request :camelcase conn.request :json # Uncomment this if you want curl command equivalent or response output to log # conn.request(:curl, ::Logger.new(STDOUT), :warn) unless Rails.env.production? # conn.response(:logger, ::Logger.new(STDOUT), bodies: true) unless Rails.env.production? conn.response :snakecase conn.response :rx_raise_error, error_prefix: service_name conn.response :mhv_errors conn.response :json_parser conn.adapter :typhoeus end end |
#service_name ⇒ String
Returns Service name to use in breakers and metrics.
48 49 50 |
# File 'lib/rx/configuration.rb', line 48 def service_name 'Rx' end |