Module: Uploadcare::Concerns::ThrottleHandler
- Defined in:
- lib/uploadcare/concern/throttle_handler.rb
Overview
This module lets clients send request multiple times if request is throttled
Instance Method Summary collapse
-
#handle_throttling { ... } ⇒ Object
call given block.
Instance Method Details
#handle_throttling { ... } ⇒ Object
call given block. If ThrottleError is returned, it will wait and attempt again 4 more times
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/uploadcare/concern/throttle_handler.rb', line 9 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 |