Class: HTTPigeon::CircuitBreaker::FuseConfig
- Inherits:
-
Object
- Object
- HTTPigeon::CircuitBreaker::FuseConfig
- Defined in:
- lib/httpigeon/circuit_breaker/fuse_config.rb
Constant Summary collapse
- DEFAULT_MM_TIMEOUT_HEADER =
'X-Maintenance-Mode-Timeout'.freeze
Instance Attribute Summary collapse
-
#error_codes_watchlist ⇒ Object
readonly
Returns the value of attribute error_codes_watchlist.
-
#failure_rate_threshold ⇒ Object
readonly
Returns the value of attribute failure_rate_threshold.
-
#maintenance_mode_header ⇒ Object
readonly
Returns the value of attribute maintenance_mode_header.
-
#max_failures_count ⇒ Object
readonly
Returns the value of attribute max_failures_count.
-
#min_failures_count ⇒ Object
readonly
Returns the value of attribute min_failures_count.
-
#on_circuit_closed ⇒ Object
readonly
Returns the value of attribute on_circuit_closed.
-
#on_circuit_opened ⇒ Object
readonly
Returns the value of attribute on_circuit_opened.
-
#open_circuit_handler ⇒ Object
readonly
Returns the value of attribute open_circuit_handler.
-
#open_circuit_sleep_window ⇒ Object
readonly
Returns the value of attribute open_circuit_sleep_window.
-
#sample_window ⇒ Object
readonly
Returns the value of attribute sample_window.
-
#service_id ⇒ Object
readonly
Returns the value of attribute service_id.
Instance Method Summary collapse
- #circuit_open_error ⇒ Object
-
#initialize(fuse_options = {}) ⇒ FuseConfig
constructor
A new instance of FuseConfig.
- #null_response(api_response = nil, exception = nil) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(fuse_options = {}) ⇒ FuseConfig
Returns a new instance of FuseConfig.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/httpigeon/circuit_breaker/fuse_config.rb', line 30 def initialize( = {}) @service_id = [:service_id].presence || raise(ArgumentError, 'service_id is required') @max_failures_count = [:max_failures_count] || HTTPigeon.fuse_max_failures_count @min_failures_count = [:min_failures_count] || HTTPigeon.fuse_min_failures_count @failure_rate_threshold = [:failure_rate_threshold] || HTTPigeon.fuse_failure_rate_threshold @sample_window = [:sample_window] || HTTPigeon.fuse_sample_window @open_circuit_sleep_window = [:open_circuit_sleep_window] || HTTPigeon.fuse_open_circuit_sleep_window @error_codes_watchlist = [:error_codes_watchlist].to_a | HTTPigeon.fuse_error_codes_watchlist.to_a @maintenance_mode_header = [:maintenance_mode_header] || DEFAULT_MM_TIMEOUT_HEADER @on_circuit_closed = HTTPigeon.fuse_on_circuit_closed @on_circuit_opened = HTTPigeon.fuse_on_circuit_opened @open_circuit_handler = if HTTPigeon.fuse_open_circuit_handler.respond_to?(:call) HTTPigeon.fuse_open_circuit_handler else ->(api_response, exception) { null_response(api_response, exception) } end end |
Instance Attribute Details
#error_codes_watchlist ⇒ Object (readonly)
Returns the value of attribute error_codes_watchlist.
18 19 20 |
# File 'lib/httpigeon/circuit_breaker/fuse_config.rb', line 18 def error_codes_watchlist @error_codes_watchlist end |
#failure_rate_threshold ⇒ Object (readonly)
Returns the value of attribute failure_rate_threshold.
18 19 20 |
# File 'lib/httpigeon/circuit_breaker/fuse_config.rb', line 18 def failure_rate_threshold @failure_rate_threshold end |
#maintenance_mode_header ⇒ Object (readonly)
Returns the value of attribute maintenance_mode_header.
18 19 20 |
# File 'lib/httpigeon/circuit_breaker/fuse_config.rb', line 18 def maintenance_mode_header @maintenance_mode_header end |
#max_failures_count ⇒ Object (readonly)
Returns the value of attribute max_failures_count.
18 19 20 |
# File 'lib/httpigeon/circuit_breaker/fuse_config.rb', line 18 def max_failures_count @max_failures_count end |
#min_failures_count ⇒ Object (readonly)
Returns the value of attribute min_failures_count.
18 19 20 |
# File 'lib/httpigeon/circuit_breaker/fuse_config.rb', line 18 def min_failures_count @min_failures_count end |
#on_circuit_closed ⇒ Object (readonly)
Returns the value of attribute on_circuit_closed.
18 19 20 |
# File 'lib/httpigeon/circuit_breaker/fuse_config.rb', line 18 def on_circuit_closed @on_circuit_closed end |
#on_circuit_opened ⇒ Object (readonly)
Returns the value of attribute on_circuit_opened.
18 19 20 |
# File 'lib/httpigeon/circuit_breaker/fuse_config.rb', line 18 def on_circuit_opened @on_circuit_opened end |
#open_circuit_handler ⇒ Object (readonly)
Returns the value of attribute open_circuit_handler.
18 19 20 |
# File 'lib/httpigeon/circuit_breaker/fuse_config.rb', line 18 def open_circuit_handler @open_circuit_handler end |
#open_circuit_sleep_window ⇒ Object (readonly)
Returns the value of attribute open_circuit_sleep_window.
18 19 20 |
# File 'lib/httpigeon/circuit_breaker/fuse_config.rb', line 18 def open_circuit_sleep_window @open_circuit_sleep_window end |
#sample_window ⇒ Object (readonly)
Returns the value of attribute sample_window.
18 19 20 |
# File 'lib/httpigeon/circuit_breaker/fuse_config.rb', line 18 def sample_window @sample_window end |
#service_id ⇒ Object (readonly)
Returns the value of attribute service_id.
18 19 20 |
# File 'lib/httpigeon/circuit_breaker/fuse_config.rb', line 18 def service_id @service_id end |
Instance Method Details
#circuit_open_error ⇒ Object
66 67 68 |
# File 'lib/httpigeon/circuit_breaker/fuse_config.rb', line 66 def circuit_open_error CircuitOpenError.new(service_id) end |
#null_response(api_response = nil, exception = nil) ⇒ Object
62 63 64 |
# File 'lib/httpigeon/circuit_breaker/fuse_config.rb', line 62 def null_response(api_response = nil, exception = nil) NullResponse.new(api_response, exception) end |
#to_h ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/httpigeon/circuit_breaker/fuse_config.rb', line 49 def to_h { service_id: service_id, max_failures_count: max_failures_count, min_failures_count: min_failures_count, failure_rate_threshold: failure_rate_threshold, sample_window: sample_window, open_circuit_sleep_window: open_circuit_sleep_window, error_codes_watchlist: error_codes_watchlist, maintenance_mode_header: maintenance_mode_header } end |