Module: ResilientCall
- Defined in:
- lib/resilient_call.rb,
lib/resilient_call/mixin.rb,
lib/resilient_call/errors.rb,
lib/resilient_call/circuit.rb,
lib/resilient_call/retrier.rb,
lib/resilient_call/version.rb,
lib/resilient_call/storage/base.rb,
lib/resilient_call/configuration.rb,
lib/resilient_call/storage/redis.rb,
lib/resilient_call/storage/memory.rb,
lib/resilient_call/circuit_breaker.rb
Defined Under Namespace
Modules: CircuitBreaker, Mixin, Storage Classes: Circuit, CircuitOpenError, Configuration, Retrier, RetriesExhaustedError
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
-
.call(**options, &block) ⇒ Object
Runs
blockwith retry and, whencircuit:is given, circuit-breaker protection. - .configuration ⇒ Object
- .configure {|configuration| ... } ⇒ Object
- .define_profile(name, **options) ⇒ Object
-
.reset_configuration! ⇒ Object
Restores global defaults — useful for isolating tests.
Class Method Details
.call(**options, &block) ⇒ Object
Runs block with retry and, when circuit: is given, circuit-breaker
protection. Option precedence: inline > profile > global config > defaults.
23 24 25 26 27 28 29 30 |
# File 'lib/resilient_call.rb', line 23 def call(**, &block) = () circuit = circuit_for() return reject_open_circuit(circuit, ) if circuit_blocking?(circuit) run_with_retry(, circuit, &block) end |
.configuration ⇒ Object
36 37 38 |
# File 'lib/resilient_call.rb', line 36 def configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
32 33 34 |
# File 'lib/resilient_call.rb', line 32 def configure yield configuration end |
.define_profile(name, **options) ⇒ Object
40 41 42 |
# File 'lib/resilient_call.rb', line 40 def define_profile(name, **) configuration.profiles[name] = end |
.reset_configuration! ⇒ Object
Restores global defaults — useful for isolating tests.
45 46 47 |
# File 'lib/resilient_call.rb', line 45 def reset_configuration! @configuration = Configuration.new end |