Class: ExpRetry

Inherits:
Object
  • Object
show all
Defined in:
lib/exp_retry.rb

Overview

Exponential backoff retry wrapper

Instance Method Summary collapse

Constructor Details

#initialize(retries: 3, exception: StandardError) ⇒ ExpRetry

Returns a new instance of ExpRetry.



5
6
7
8
# File 'lib/exp_retry.rb', line 5

def initialize(retries: 3, exception: StandardError)
  @retries = retries
  @exception = exception
end

Instance Method Details

#callObject



10
11
12
13
14
15
# File 'lib/exp_retry.rb', line 10

def call
  yield if block_given?
rescue *@exception => e
  check(e)
  retry
end