Class: BarbequeClient::ExponentialRetry
- Inherits:
-
Object
- Object
- BarbequeClient::ExponentialRetry
- Defined in:
- lib/barbeque_client/exponential_retry.rb
Constant Summary collapse
- MAX_DELAY_SECONDS =
(ENV['BARBEQUE_MAX_RETRY_DELAY'] || 900).to_i
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(count) ⇒ ExponentialRetry
constructor
A new instance of ExponentialRetry.
- #retry(message_id) ⇒ Object
Constructor Details
#initialize(count) ⇒ ExponentialRetry
Returns a new instance of ExponentialRetry.
12 13 14 |
# File 'lib/barbeque_client/exponential_retry.rb', line 12 def initialize(count) @count = count end |
Class Method Details
.exponential_backoff(count) ⇒ Integer
7 8 9 |
# File 'lib/barbeque_client/exponential_retry.rb', line 7 def self.exponential_backoff(count) (count ** 4) + 15 + (rand(30) * (count + 1)) end |
Instance Method Details
#retry(message_id) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/barbeque_client/exponential_retry.rb', line 17 def retry() BarbequeClient.client.retry_execution( message_id: , delay_seconds: [delay_seconds, MAX_DELAY_SECONDS].min, ) end |