Sha256: d6ccd565e6bfadb1ac5f657820ae0ef1b5651d89d44700325bac861a540f4fd0
Contents?: true
Size: 1.01 KB
Versions: 63
Compression:
Stored size: 1.01 KB
Contents
require 'aws-sdk' require 'contracts' require 'retries' module Cloudstrap module Amazon module Support module RateLimitHandler include ::Contracts::Core include ::Contracts::Builtin Contract None => Proc def request_limit_exceeded_handler Proc.new do |exception, attempt, seconds| STDERR.puts "Encountered a #{exception.class}. DON'T PANIC. Waiting and trying again works (usually). Let's do that! (this was attempt #{attempt} after #{seconds} seconds)" end end Contract Symbol, Args[Any] => Any def call_api(method, *args) with_retries( rescue: [ Aws::EC2::Errors::RequestLimitExceeded, Aws::Route53::Errors::ThrottlingException ], handler: request_limit_exceeded_handler, base_sleep_seconds: 1.0, max_sleep_seconds: 8.0 ) do api.method(method).call(*args) end end end end end end
Version data entries
63 entries across 63 versions & 1 rubygems