Class: DecisionReview::Configuration
- Inherits:
-
Common::Client::Configuration::REST
- Object
- Common::Client::Configuration::Base
- Common::Client::Configuration::REST
- DecisionReview::Configuration
- Defined in:
- lib/decision_review/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.
Direct Known Subclasses
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 decision review API call.
Instance Method Summary collapse
-
#base_path ⇒ String
Base path for decision review URLs.
- #breakers_error_threshold ⇒ Object
-
#connection ⇒ Faraday::Connection
Creates the a connection with parsing json and adding breakers functionality.
-
#mock_enabled? ⇒ Boolean
Should the service use mock data in lower environments.
-
#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
Class Method Details
.base_request_headers ⇒ Hash
Returns The basic headers required for any decision review API call.
31 32 33 |
# File 'lib/decision_review/configuration.rb', line 31 def self.base_request_headers super.merge('apiKey' => Settings.decision_review.api_key) end |
Instance Method Details
#base_path ⇒ String
Returns Base path for decision review URLs.
17 18 19 |
# File 'lib/decision_review/configuration.rb', line 17 def base_path Settings.decision_review.url end |
#breakers_error_threshold ⇒ Object
61 62 63 |
# File 'lib/decision_review/configuration.rb', line 61 def breakers_error_threshold 80 # breakers will be tripped if error rate reaches 80% over a two minute period. end |
#connection ⇒ Faraday::Connection
Creates the a connection with parsing json and adding breakers functionality.
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/decision_review/configuration.rb', line 40 def connection @conn ||= Faraday.new(base_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 mock_enabled? faraday.response :json faraday.adapter Faraday.default_adapter end end |
#mock_enabled? ⇒ Boolean
Returns Should the service use mock data in lower environments.
57 58 59 |
# File 'lib/decision_review/configuration.rb', line 57 def mock_enabled? Settings.decision_review.mock || false end |
#service_name ⇒ String
Returns Service name to use in breakers and metrics.
24 25 26 |
# File 'lib/decision_review/configuration.rb', line 24 def service_name 'DecisionReview' end |