Module: BreakerMachines::HedgedAsyncSupport
- Defined in:
- lib/breaker_machines/hedged_async_support.rb
Overview
AsyncSupport for HedgedExecution
Instance Method Summary collapse
-
#execute_hedged_with_async(callables, delay_ms) ⇒ Object
Execute hedged requests with configurable delay between attempts.
-
#execute_parallel_fallbacks_async(fallbacks) ⇒ Object
Execute parallel fallbacks without delay.
Instance Method Details
#execute_hedged_with_async(callables, delay_ms) ⇒ Object
Execute hedged requests with configurable delay between attempts
21 22 23 |
# File 'lib/breaker_machines/hedged_async_support.rb', line 21 def execute_hedged_with_async(callables, delay_ms) race_tasks(callables, delay_ms: delay_ms) end |
#execute_parallel_fallbacks_async(fallbacks) ⇒ Object
Execute parallel fallbacks without delay
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/breaker_machines/hedged_async_support.rb', line 29 def execute_parallel_fallbacks_async(fallbacks) # Normalize fallbacks to callables callables = fallbacks.map do |fallback| case fallback when Proc # Handle procs with different arities -> { fallback.arity == 1 ? fallback.call(nil) : fallback.call } else # Wrap static values in callables -> { fallback } end end race_tasks(callables, delay_ms: 0) end |