Module: EasyRetry

Defined in:
lib/easy_retry.rb,
lib/easy_retry/version.rb,
lib/easy_retry/configuration.rb

Overview

EasyRetry core module

Defined Under Namespace

Classes: Configuration

Constant Summary collapse

VERSION =
'1.0.8.1'

Class Method Summary collapse

Class Method Details

.configurationObject



10
11
12
# File 'lib/easy_retry.rb', line 10

def configuration
  @configuration ||= EasyRetry::Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



14
15
16
# File 'lib/easy_retry.rb', line 14

def configure
  yield(configuration)
end

.delay_algorithmObject



22
23
24
# File 'lib/easy_retry.rb', line 22

def delay_algorithm
  configuration.delay_algorithm
end

.delay_optionsObject



26
27
28
29
30
31
32
33
# File 'lib/easy_retry.rb', line 26

def delay_options
  {
    none: ->(_try_number) {},
    by_try: ->(try_number) { sleep try_number },
    default: ->(try_number) { sleep try_number * try_number },
    exponential: ->(try_number) { sleep 2**try_number }
  }
end

.loggerObject



18
19
20
# File 'lib/easy_retry.rb', line 18

def logger
  configuration.logger
end