Class: BenefitsIntake::Configuration
- Inherits:
-
Common::Client::Configuration::REST
- Object
- Common::Client::Configuration::Base
- Common::Client::Configuration::REST
- BenefitsIntake::Configuration
- Defined in:
- lib/lighthouse/benefits_intake/configuration.rb
Overview
HTTP client configuration for the Service, sets the base path, the base request headers, 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
Class Method Summary collapse
-
.base_request_headers ⇒ Hash
The basic headers required for any Lighthouse API call.
Instance Method Summary collapse
- #breakers_error_threshold ⇒ Object
-
#connection ⇒ Faraday::Connection
Creates a connection with json parsing and breaker functionality.
-
#intake_settings ⇒ Config::Options
Settings for benefits_claims API.
-
#service_name ⇒ String
Service name to use in breakers and metrics.
-
#service_path ⇒ String
Base path.
-
#use_mocks? ⇒ Boolean
Should the service use mock data in lower environments.
Methods inherited from Common::Client::Configuration::Base
#base_path, #breakers_exception_handler, #breakers_matcher, #breakers_service, #create_new_breakers_service, #current_module, #request_options, #service_exception
Class Method Details
.base_request_headers ⇒ Hash
Returns The basic headers required for any Lighthouse API call.
39 40 41 42 43 44 |
# File 'lib/lighthouse/benefits_intake/configuration.rb', line 39 def self.base_request_headers key = Settings.lighthouse.benefits_intake.api_key raise "No api_key set for benefits_intake. Please set 'lighthouse.benefits_intake.api_key'" if key.nil? super.merge('apikey' => key) end |
Instance Method Details
#breakers_error_threshold ⇒ Object
72 73 74 |
# File 'lib/lighthouse/benefits_intake/configuration.rb', line 72 def breakers_error_threshold 80 # breakers will be tripped if error rate reaches 80% over a two minute period. end |
#connection ⇒ Faraday::Connection
Creates a connection with json parsing and breaker functionality.
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/lighthouse/benefits_intake/configuration.rb', line 51 def connection @conn ||= Faraday.new(service_path, headers: base_request_headers, request: ) do |faraday| faraday.use :breakers faraday.use Faraday::Response::RaiseError faraday.request :multipart faraday.request :json faraday.response :betamocks if use_mocks? faraday.response :json faraday.adapter Faraday.default_adapter end end |
#intake_settings ⇒ Config::Options
Returns Settings for benefits_claims API.
17 18 19 |
# File 'lib/lighthouse/benefits_intake/configuration.rb', line 17 def intake_settings Settings.lighthouse.benefits_intake end |
#service_name ⇒ String
Returns Service name to use in breakers and metrics.
32 33 34 |
# File 'lib/lighthouse/benefits_intake/configuration.rb', line 32 def service_name 'BenefitsIntake' end |
#service_path ⇒ String
Returns Base path.
24 25 26 27 |
# File 'lib/lighthouse/benefits_intake/configuration.rb', line 24 def service_path url = [intake_settings.host, intake_settings.path, intake_settings.version] url.map { |segment| segment.sub(%r{^/}, '').chomp('/') }.join('/') end |
#use_mocks? ⇒ Boolean
Returns Should the service use mock data in lower environments.
68 69 70 |
# File 'lib/lighthouse/benefits_intake/configuration.rb', line 68 def use_mocks? intake_settings.use_mocks || false end |