Sha256: 020c5feaaff1921bac38cdc9cca7d9eb8e69d00e0bdc22a41a25301693d51b5d

Contents?: true

Size: 538 Bytes

Versions: 4

Compression:

Stored size: 538 Bytes

Contents

require 'retryable'

module DaemonRunner
  #
  # Retry Errors
  #
  class RetryErrors
    extend Logger

    class << self
      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
daemon_runner-0.4.3 lib/daemon_runner/retry_errors.rb
daemon_runner-0.4.2 lib/daemon_runner/retry_errors.rb
daemon_runner-0.4.1 lib/daemon_runner/retry_errors.rb
daemon_runner-0.4.0 lib/daemon_runner/retry_errors.rb