Class: DaemonRunner::RetryErrors

Inherits:
Object
  • Object
show all
Extended by:
Logger
Defined in:
lib/daemon_runner/retry_errors.rb

Overview

Retry Errors

Class Method Summary collapse

Methods included from Logger

logger, logger_name

Class Method Details

.retry(retries: 3, exceptions: [Faraday::ClientError], &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/daemon_runner/retry_errors.rb', line 11

def retry(retries: 3, exceptions: [Faraday::ClientError], &block)
  properties = {
    on: exceptions,
    sleep: lambda { |c| 2**c * 0.3 },
    tries: retries
  }
  Retryable.retryable(properties) do |retries, exception|
    logger.warn "try #{retries} failed with exception: #{exception}" if retries > 0
    block.call
  end
end