Class: FaradayMiddleware::CircuitBreaker::OptionSet
- Inherits:
-
Object
- Object
- FaradayMiddleware::CircuitBreaker::OptionSet
- Defined in:
- lib/faraday_middleware/circuit_breaker/option_set.rb
Constant Summary collapse
- VALID_OPTIONS =
%w(timeout threshold fallback notifiers data_store error_handler cache_key_generator)
Instance Attribute Summary collapse
-
#cache_key_generator ⇒ Object
Returns the value of attribute cache_key_generator.
-
#data_store ⇒ Object
Returns the value of attribute data_store.
-
#error_handler ⇒ Object
Returns the value of attribute error_handler.
-
#fallback ⇒ Object
Returns the value of attribute fallback.
-
#notifiers ⇒ Object
Returns the value of attribute notifiers.
-
#threshold ⇒ Object
Returns the value of attribute threshold.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ OptionSet
constructor
A new instance of OptionSet.
Constructor Details
#initialize(options = {}) ⇒ OptionSet
Returns a new instance of OptionSet.
13 14 15 16 17 18 19 20 21 |
# File 'lib/faraday_middleware/circuit_breaker/option_set.rb', line 13 def initialize( = {}) @timeout = [:timeout] || 60.0 @threshold = [:threshold] || 3 @fallback = [:fallback] || proc { Faraday::Response.new(status: 503, response_headers: {}) } @notifiers = [:notifiers] || {} @data_store = [:data_store] || proc { Stoplight::Light.default_data_store } @error_handler = [:error_handler] || Stoplight::Default::ERROR_HANDLER @cache_key_generator = [:cache_key_generator] || ->(url) { URI.join(url, '/').to_s } end |
Instance Attribute Details
#cache_key_generator ⇒ Object
Returns the value of attribute cache_key_generator.
11 12 13 |
# File 'lib/faraday_middleware/circuit_breaker/option_set.rb', line 11 def cache_key_generator @cache_key_generator end |
#data_store ⇒ Object
Returns the value of attribute data_store.
11 12 13 |
# File 'lib/faraday_middleware/circuit_breaker/option_set.rb', line 11 def data_store @data_store end |
#error_handler ⇒ Object
Returns the value of attribute error_handler.
11 12 13 |
# File 'lib/faraday_middleware/circuit_breaker/option_set.rb', line 11 def error_handler @error_handler end |
#fallback ⇒ Object
Returns the value of attribute fallback.
11 12 13 |
# File 'lib/faraday_middleware/circuit_breaker/option_set.rb', line 11 def fallback @fallback end |
#notifiers ⇒ Object
Returns the value of attribute notifiers.
11 12 13 |
# File 'lib/faraday_middleware/circuit_breaker/option_set.rb', line 11 def notifiers @notifiers end |
#threshold ⇒ Object
Returns the value of attribute threshold.
11 12 13 |
# File 'lib/faraday_middleware/circuit_breaker/option_set.rb', line 11 def threshold @threshold end |
#timeout ⇒ Object
Returns the value of attribute timeout.
11 12 13 |
# File 'lib/faraday_middleware/circuit_breaker/option_set.rb', line 11 def timeout @timeout end |
Class Method Details
.validate!(options) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/faraday_middleware/circuit_breaker/option_set.rb', line 23 def self.validate!() .each_key do |key| unless VALID_OPTIONS.include?(key.to_s) fail ArgumentError.new("Unknown option: #{key}. Valid options are :#{VALID_OPTIONS.join(', ')}") end end end |