/shopify_api_retry

Retry a Shopify API request if an HTTP 429 (too many requests) is returned

Primary LanguageRubyMIT LicenseMIT

ShopifyAPIRetry

Simple module to retry a ShopifyAPI request if an HTTP 429 (too many requests) is returned. No monkey patching.

Usage

require "shopify_api_retry"

ShopifyAPIRetry.retry { customer.update_attribute(:tags, "foo")  }
ShopifyAPIRetry.retry(30) { customer.update_attribute(:tags, "foo") }  # Retry after 30 seconds on HTTP 429
customer = ShopifyAPIRetry.retry { ShopifyAPI::Customer.find(id) }

If no retry time is provided the value of the HTTP header Retry-After is used. If it's not given (it always is) 2 is used.

If the retry fails the original error is raised (ActiveResource::ClientError or subclass).

Installation

Bundler:

gem "shopify_api_retry"

Gem:

gem install shopify_api_retry

License

Released under the MIT License: www.opensource.org/licenses/MIT


Made by ScreenStaring