Module: Itrp::SendWithRateLimitBlock
- Defined in:
- lib/itrp/client.rb
Instance Method Summary collapse
-
#_send(request, domain = @domain, port = @port, ssl = @ssl) ⇒ Object
Wraps the _send method with retries when the server does not responsd, see
initialize
option:rate_limit_block
.
Instance Method Details
#_send(request, domain = @domain, port = @port, ssl = @ssl) ⇒ Object
Wraps the _send method with retries when the server does not responsd, see initialize
option :rate_limit_block
300 301 302 303 304 305 306 307 308 |
# File 'lib/itrp/client.rb', line 300 def _send(request, domain = @domain, port = @port, ssl = @ssl) return super(request, domain, port, ssl) unless option(:block_at_rate_limit) now = Time.now begin _response = super(request, domain, port, ssl) @logger.warn { "Request throttled, trying again in 5 minutes: #{_response.}" } and sleep(300) if _response.throttled? end while _response.throttled? && (Time.now - now) < 3660 # max 1 hour and 1 minute _response end |