Class: Aidp::Harness::ErrorHandler::BackoffCalculator
- Inherits:
-
Object
- Object
- Aidp::Harness::ErrorHandler::BackoffCalculator
- Defined in:
- lib/aidp/harness/error_handler.rb
Overview
Helper classes
Instance Method Summary collapse
Instance Method Details
#calculate_delay(retry_count, strategy, base_delay, max_delay) ⇒ Object
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 |
# File 'lib/aidp/harness/error_handler.rb', line 572 def calculate_delay(retry_count, strategy, base_delay, max_delay) case strategy when :exponential delay = base_delay * (2**(retry_count - 1)) when :linear delay = base_delay * retry_count when :fixed delay = base_delay when :none return 0.0 else delay = base_delay end # Apply jitter if enabled if strategy != :none jitter = delay * 0.1 * (rand - 0.5) # ±10% jitter delay += jitter end # Cap at max delay [delay, max_delay].min end |