Class: ResilientCall::Configuration
- Inherits:
-
Object
- Object
- ResilientCall::Configuration
- Defined in:
- lib/resilient_call/configuration.rb
Overview
Holds the global defaults and the registry of named profiles.
Instance Attribute Summary collapse
-
#base_wait ⇒ Object
retry.
-
#circuit_storage ⇒ Object
circuit state backend (Storage::Memory by default, Storage::Redis for multi-process setups); shared by every named circuit.
-
#jitter ⇒ Object
retry.
-
#max_wait ⇒ Object
retry.
-
#on ⇒ Object
retry.
-
#on_failure ⇒ Object
callbacks.
-
#on_retry ⇒ Object
callbacks.
-
#on_success ⇒ Object
callbacks.
-
#profiles ⇒ Object
named profiles registry.
-
#reset_timeout ⇒ Object
circuit breaker.
-
#retries ⇒ Object
retry.
-
#threshold ⇒ Object
circuit breaker.
-
#wait ⇒ Object
retry.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#to_h ⇒ Object
Every default except the profiles registry, ready to be merged in
.call.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/resilient_call/configuration.rb', line 22 def initialize @retries = 3 @wait = :exponential @base_wait = 0.5 @max_wait = 30.0 @jitter = true @on = [StandardError] @threshold = 5 @reset_timeout = 60 @on_retry = nil @on_failure = nil @on_success = nil @circuit_storage = Storage::Memory.new @profiles = {} end |
Instance Attribute Details
#base_wait ⇒ Object
retry
9 10 11 |
# File 'lib/resilient_call/configuration.rb', line 9 def base_wait @base_wait end |
#circuit_storage ⇒ Object
circuit state backend (Storage::Memory by default, Storage::Redis for multi-process setups); shared by every named circuit
18 19 20 |
# File 'lib/resilient_call/configuration.rb', line 18 def circuit_storage @circuit_storage end |
#jitter ⇒ Object
retry
9 10 11 |
# File 'lib/resilient_call/configuration.rb', line 9 def jitter @jitter end |
#max_wait ⇒ Object
retry
9 10 11 |
# File 'lib/resilient_call/configuration.rb', line 9 def max_wait @max_wait end |
#on ⇒ Object
retry
9 10 11 |
# File 'lib/resilient_call/configuration.rb', line 9 def on @on end |
#on_failure ⇒ Object
callbacks
15 16 17 |
# File 'lib/resilient_call/configuration.rb', line 15 def on_failure @on_failure end |
#on_retry ⇒ Object
callbacks
15 16 17 |
# File 'lib/resilient_call/configuration.rb', line 15 def on_retry @on_retry end |
#on_success ⇒ Object
callbacks
15 16 17 |
# File 'lib/resilient_call/configuration.rb', line 15 def on_success @on_success end |
#profiles ⇒ Object
named profiles registry
20 21 22 |
# File 'lib/resilient_call/configuration.rb', line 20 def profiles @profiles end |
#reset_timeout ⇒ Object
circuit breaker
12 13 14 |
# File 'lib/resilient_call/configuration.rb', line 12 def reset_timeout @reset_timeout end |
#retries ⇒ Object
retry
9 10 11 |
# File 'lib/resilient_call/configuration.rb', line 9 def retries @retries end |
#threshold ⇒ Object
circuit breaker
12 13 14 |
# File 'lib/resilient_call/configuration.rb', line 12 def threshold @threshold end |
#wait ⇒ Object
retry
9 10 11 |
# File 'lib/resilient_call/configuration.rb', line 9 def wait @wait end |
Instance Method Details
#to_h ⇒ Object
Every default except the profiles registry, ready to be merged in .call.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/resilient_call/configuration.rb', line 41 def to_h { retries: @retries, wait: @wait, base_wait: @base_wait, max_wait: @max_wait, jitter: @jitter, on: @on, threshold: @threshold, reset_timeout: @reset_timeout, on_retry: @on_retry, on_failure: @on_failure, on_success: @on_success } end |