Module: BreakerMachines::Circuit::Execution

Extended by:
ActiveSupport::Concern
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

Instance Method Summary collapse

Class Method Details

.load_async_supportObject

Lazy load async support only when needed



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/breaker_machines/circuit/execution.rb', line 11

def self.load_async_support
  require 'breaker_machines/async_support'
  require 'breaker_machines/hedged_async_support'
  Circuit.include(BreakerMachines::AsyncSupport)
  Circuit.include(BreakerMachines::HedgedAsyncSupport)
rescue LoadError => e
  if e.message.include?('async')
    raise LoadError, "The 'async' gem is required for fiber_safe mode. Add `gem 'async'` to your Gemfile."
  end

  raise
end

Instance Method Details

#callObject



24
25
26
# File 'lib/breaker_machines/circuit/execution.rb', line 24

def call(&)
  wrap(&)
end

#wrapObject



28
29
30
# File 'lib/breaker_machines/circuit/execution.rb', line 28

def wrap(&)
  execute_with_state_check(&)
end