Class: Bogo::Retry::Exponential

Inherits:
Bogo::Retry show all
Defined in:
lib/bogo/retry.rb

Overview

Exponential retry implementation

Instance Attribute Summary collapse

Attributes inherited from Bogo::Retry

#action, #attempts, #dead, #description, #max_attempts, #ui

Instance Method Summary collapse

Methods inherited from Bogo::Retry

build, #retries, #run!

Constructor Details

#initialize(args = {}, &block) ⇒ self

Create a new linear retry instance

Parameters:

  • args (Hash) (defaults to: {})

Options Hash (args):

  • :wait_interval (Numeric)

    Defaults to 5 seconds

  • :wait_exponent (Numeric)

    Defaults to 2



174
175
176
177
178
179
180
181
182
183
184
# File 'lib/bogo/retry.rb', line 174

def initialize(args={}, &block)
  @wait_interval = args[:wait_interval].to_f
  @wait_exponent = args[:wait_exponent].to_f
  unless(@wait_interval > 0)
    @wait_interval = 5
  end
  unless(@wait_exponent > 0)
    @wait_exponent = 2
  end
  super
end

Instance Attribute Details

#wait_exponentNumeric (readonly)

Returns:

  • (Numeric)


166
167
168
# File 'lib/bogo/retry.rb', line 166

def wait_exponent
  @wait_exponent
end

#wait_intervalNumeric (readonly)

Returns:

  • (Numeric)


164
165
166
# File 'lib/bogo/retry.rb', line 164

def wait_interval
  @wait_interval
end