Class: BreakerMachines::AsyncCircuit
- Includes:
- Circuit::AsyncStateManagement
- Defined in:
- lib/breaker_machines/async_circuit.rb
Overview
AsyncCircuit provides a circuit breaker with async-enabled state machine for thread-safe, fiber-safe concurrent operations
Instance Method Summary collapse
-
#call_async(&block) ⇒ Object
Additional async-specific methods.
-
#fire_async(event_name) ⇒ Async::Task
Fire state transition events asynchronously.
-
#health_check_async ⇒ Object
Check circuit health asynchronously Useful for monitoring multiple circuits concurrently.
Methods included from Circuit::Base
Instance Method Details
#call_async(&block) ⇒ Object
Additional async-specific methods
14 15 16 17 18 19 20 |
# File 'lib/breaker_machines/async_circuit.rb', line 14 def call_async(&block) require 'async' unless defined?(::Async) Async do call(&block) end end |
#fire_async(event_name) ⇒ Async::Task
Fire state transition events asynchronously
25 26 27 28 29 |
# File 'lib/breaker_machines/async_circuit.rb', line 25 def fire_async(event_name) require 'async' unless defined?(::Async) fire_event_async(event_name) end |
#health_check_async ⇒ Object
Check circuit health asynchronously Useful for monitoring multiple circuits concurrently
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/breaker_machines/async_circuit.rb', line 33 def health_check_async require 'async' unless defined?(::Async) Async do { name: @name, status: status_name, open: open?, stats: stats.to_h, can_recover: open? && reset_timeout_elapsed? } end end |