Module: BreakerMachines::Circuit::Execution
- Extended by:
- ActiveSupport::Concern
- Included in:
- BreakerMachines::Circuit
- Defined in:
- lib/breaker_machines/circuit/execution.rb
Overview
Execution handles the core circuit breaker logic including call wrapping, state-based request handling, and failure/success tracking.
Class Method Summary collapse
-
.load_async_support ⇒ Object
Lazy load async support only when needed.
Instance Method Summary collapse
Class Method Details
.load_async_support ⇒ Object
Lazy load async support only when needed
11 12 13 14 15 16 |
# File 'lib/breaker_machines/circuit/execution.rb', line 11 def self.load_async_support require 'async' require 'async/task' rescue LoadError raise LoadError, "The 'async' gem is required for fiber_safe mode. Add `gem 'async'` to your Gemfile." end |
Instance Method Details
#call ⇒ Object
18 19 20 |
# File 'lib/breaker_machines/circuit/execution.rb', line 18 def call(&) wrap(&) end |
#wrap(&block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/breaker_machines/circuit/execution.rb', line 22 def wrap(&block) @mutex.with_read_lock do case status_name when :open handle_open_status(&block) when :half_open handle_half_open_status(&block) when :closed handle_closed_status(&block) end end end |