Sha256: 89deca54f8a551a0b85c3a39b47c68e27ab47541f7feebca0c4fce1f3a7d5306
Contents?: true
Size: 736 Bytes
Versions: 1
Compression:
Stored size: 736 Bytes
Contents
require "retrying_s3_client/version" require "aws-sdk-s3" class RetryingS3Client def self.wrap(s3, logger, options) return s3 if s3.is_a?(RetryingS3Client) new(s3, logger, options) end def initialize(s3, logger, options = {}) @s3 = s3 @logger = logger @sleeper = options[:sleeper] || Kernel.method(:sleep) end def method_missing(sym, *args, &block) with_backoff { @s3.send(sym, *args, &block) } end def with_backoff(backoff = 1) yield rescue Aws::S3::Errors::Http503Error @logger.error "Got Aws::S3::Errors::Http503Error, sleeping #{backoff}" @sleeper.call(backoff) @logger.info "Woke up after Aws::S3::Errors::Http503Error retrying again" backoff *= 2 retry end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
retrying_s3_client-0.1.0 | lib/retrying_s3_client.rb |