Module: RetryHandler

Defined in:
lib/retry-handler.rb

Constant Summary collapse

DEFAULT_MAX_RETRY =
3
DEFAULT_WAIT_TIME =
1
INFINITY_EXECUTE =
nil

Class Method Summary collapse

Class Method Details

.retry_handler(options = {}, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/retry-handler.rb', line 12

def self.retry_handler(options={}, &block)
  max = options[:max] || DEFAULT_MAX_RETRY
  wait = options[:wait] || DEFAULT_WAIT_TIME
  timeout = options[:timeout] || INFINITY_EXECUTE
  exception = options[:accept_exception] || RetryError 
  logger = options[:logger] || Logger.new(nil)

  _retry_handler(max, wait, exception, logger) do
    timeout(timeout, RetryError) do
      block.call
    end
  end
end