Class: ChronoForge::Executor::RetryStrategy
- Inherits:
-
Object
- Object
- ChronoForge::Executor::RetryStrategy
- Defined in:
- lib/chrono_forge/executor/retry_strategy.rb
Constant Summary collapse
- BACKOFF_STRATEGY =
[ 1.second, # Initial retry 5.seconds, # Second retry 30.seconds, # Third retry 2.minutes, # Fourth retry 10.minutes # Final retry ]
Class Method Summary collapse
Class Method Details
.max_attempts ⇒ Object
24 25 26 |
# File 'lib/chrono_forge/executor/retry_strategy.rb', line 24 def self.max_attempts BACKOFF_STRATEGY.length end |
.schedule_retry(workflow, attempt: 0) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/chrono_forge/executor/retry_strategy.rb', line 12 def self.schedule_retry(workflow, attempt: 0) wait_duration = BACKOFF_STRATEGY[attempt] || BACKOFF_STRATEGY.last # Schedule with exponential backoff workflow.job_klass .set(wait: wait_duration) .perform_later( workflow.key, attempt: attempt + 1 ) end |