Sha256: dac232bc25753c3f0fa1e2f3a2ad7bc0f80c8a79f2ae3df7030e3bdc2553f4ba
Contents?: true
Size: 771 Bytes
Versions: 21
Compression:
Stored size: 771 Bytes
Contents
# frozen_string_literal: true module Uploadcare module Concerns # This module lets clients send request multiple times if request is throttled module ThrottleHandler # call given block. If ThrottleError is returned, it will wait and attempt again 4 more times # @yield executable block (HTTP request that may be throttled) def handle_throttling (Uploadcare.config.max_throttle_attempts - 1).times do # rubocop:disable Style/RedundantBegin begin return yield rescue(Exception::ThrottleError) => e wait_time = e.timeout sleep(wait_time) next end # rubocop:enable Style/RedundantBegin end yield end end end end
Version data entries
21 entries across 21 versions & 1 rubygems