in lib/connectors/base/custom_client.rb [89:108]
def request_with_throttling(method, url, options = {})
response =
if send_body?(method)
public_send(method, url, options[:body], options[:headers])
else
public_send(method, url, options[:params], options[:headers])
end
if response.status == 429
retry_after = response.headers['Retry-After']
multiplier = options.fetch(:retry_mulitplier, 1)
retry_after_secs = (retry_after.is_a?(Array) ? retry_after.first.to_i : retry_after.to_i) * multiplier
retry_after_secs = 60 if retry_after_secs <= 0
Utility::Logger.warn("Exceeded #{self.class} request limits. Going to sleep for #{retry_after_secs} seconds")
raise Utility::ThrottlingError.new(:suspend_until => DateTime.now + retry_after_secs.seconds, :cursors => options[:cursors])
else
response
end
end